From 61e5ee0b8e9dd765a01b5ba57e895ad1351c8d23 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 09:41:12 -0800 Subject: [PATCH 01/23] chore(quest): claim quest/m0/ux/go-live.md Quest-Claim: 54c7dbbff84a419c From 754917ee10cf0452aeb82c8f119238fb386f774a Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 11:11:44 -0800 Subject: [PATCH 02/23] feat!: go live and end the stream from the window The studio starts with no arguments on a library of recent shows, and goes live only when the broadcaster says so, from a go-live sheet with its destinations and checks, and ends the stream from the live control, held. - Off air the studio composes, previews, and records with no publishing session. Going live dials each relay, opens the program's encoders, and announces a broadcast of its own; ending finishes every track and the catalog, then closes the sessions once the relays have the tail, as quitting does. Broadcast sources, guests, and viewer reports arrive over subscribe-only sessions that stay up off air. - Where a show streams lives in `.stream.toml` beside the scene file, edited in Settings, Stream. Relay tokens go in the OS credential store. `--connect`, `--connect-token`, `--failover`, `--broadcast`, `--on-demand`, `--recordings`, and the guest flags override it for one run and are never written back. - The go-live sheet switches each relay, shows its state, and checks the camera, the microphone's level, the encoder (setup's probe), and the connection (setup's uplink probe, to the relay about to be used). A failed check is one sentence and its fix, and never blocks the confirm. - Off air the frame is neutral with an amber OFF AIR tag, the program's pad reads FIRST, and the control is GO LIVE; on air it is the clock, which reads END STREAM under the pointer. The health dot opens the worst problem, every destination, the viewers, and the encoder. - Go live and End stream are hotkey actions. - A replay of the program says it has no past off air. BREAKING CHANGE: nothing is published at launch any more; go live from the window or its hotkey. `--broadcast` has no default of its own (the show's setting, `studio` until set), and the Flatpak's menu entry opens the library instead of a fixed scene file. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 201 ++- README.md | 205 ++- packaging/flatpak/live.kixel.studio.yml | 2 + packaging/flatpak/moq-studio-desktop.sh | 7 +- packaging/flatpak/smoke.sh | 5 +- quest/m0/destinations.md | 5 +- quest/m0/ux/first-run.md | 1 - quest/m0/ux/go-live.md | 74 - quest/m0/ux/settings.md | 8 +- quest/m1/dual-format.md | 1 - quest/m1/obs-import.md | 1 - quest/m2/phone-remote.md | 4 - rs/moq-studio/Cargo.toml | 18 + rs/moq-studio/assets/icons/check.svg | 14 + rs/moq-studio/assets/icons/cpu.svg | 27 + rs/moq-studio/assets/icons/folder-open.svg | 14 + .../assets/icons/rectangle-horizontal.svg | 14 + .../assets/icons/rectangle-vertical.svg | 14 + rs/moq-studio/assets/icons/triangle-alert.svg | 16 + rs/moq-studio/assets/icons/upload.svg | 16 + rs/moq-studio/src/controls.rs | 87 +- rs/moq-studio/src/engine.rs | 1031 ++++++-------- rs/moq-studio/src/engine/air.rs | 710 ++++++++++ rs/moq-studio/src/feed.rs | 112 +- rs/moq-studio/src/guests.rs | 36 +- rs/moq-studio/src/health.rs | 3 +- rs/moq-studio/src/hotkeys/portal.rs | 2 + rs/moq-studio/src/kit/icon.rs | 26 +- rs/moq-studio/src/kit/widgets.rs | 41 +- rs/moq-studio/src/library.rs | 689 ++++++++++ rs/moq-studio/src/main.rs | 417 +++--- rs/moq-studio/src/replay.rs | 11 +- rs/moq-studio/src/setup.rs | 47 +- rs/moq-studio/src/shots.rs | 224 ++- rs/moq-studio/src/show.rs | 108 ++ rs/moq-studio/src/stream.rs | 600 ++++++++ rs/moq-studio/src/ui.rs | 51 +- rs/moq-studio/src/ui/build.rs | 4 +- rs/moq-studio/src/ui/live.rs | 1203 +++++++++++++++++ rs/moq-studio/src/ui/settings.rs | 17 +- rs/moq-studio/src/ui/shell.rs | 149 +- 41 files changed, 4984 insertions(+), 1231 deletions(-) delete mode 100644 quest/m0/ux/go-live.md create mode 100644 rs/moq-studio/assets/icons/check.svg create mode 100644 rs/moq-studio/assets/icons/cpu.svg create mode 100644 rs/moq-studio/assets/icons/folder-open.svg create mode 100644 rs/moq-studio/assets/icons/rectangle-horizontal.svg create mode 100644 rs/moq-studio/assets/icons/rectangle-vertical.svg create mode 100644 rs/moq-studio/assets/icons/triangle-alert.svg create mode 100644 rs/moq-studio/assets/icons/upload.svg create mode 100644 rs/moq-studio/src/engine/air.rs create mode 100644 rs/moq-studio/src/library.rs create mode 100644 rs/moq-studio/src/show.rs create mode 100644 rs/moq-studio/src/stream.rs create mode 100644 rs/moq-studio/src/ui/live.rs diff --git a/Cargo.lock b/Cargo.lock index bf4fa058..ccceada5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,6 +123,17 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" +[[package]] +name = "aes" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fc36d7440d015b45468ba08a21e80e056ebbd014c611c6298bb7503e04bd1" +dependencies = [ + "cipher", + "cpubits", + "cpufeatures", +] + [[package]] name = "ahash" version = "0.8.12" @@ -333,6 +344,17 @@ dependencies = [ "serde", ] +[[package]] +name = "apple-native-keyring-store" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b350bfd03649e07aa05c0a81b3e15934374e585c98204a57e20b9d49f49bb9a" +dependencies = [ + "keyring-core", + "log", + "security-framework", +] + [[package]] name = "arboard" version = "3.7.0" @@ -955,6 +977,15 @@ dependencies = [ "hybrid-array", ] +[[package]] +name = "block-padding" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "710f1dd022ef4e93f8a438b4ba958de7f64308434fa6a87104481645cc30068b" +dependencies = [ + "hybrid-array", +] + [[package]] name = "block2" version = "0.5.1" @@ -1149,6 +1180,15 @@ dependencies = [ "wayland-client", ] +[[package]] +name = "cbc" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce2dc9ee5f88d11e0beb842c88b33c8a5cf0d1329c4b19494af42b07dbfe8896" +dependencies = [ + "cipher", +] + [[package]] name = "cc" version = "1.11.1" @@ -1258,6 +1298,16 @@ dependencies = [ "windows-link", ] +[[package]] +name = "cipher" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c" +dependencies = [ + "crypto-common", + "inout", +] + [[package]] name = "clang-sys" version = "1.9.1" @@ -1327,6 +1377,12 @@ dependencies = [ "cc", ] +[[package]] +name = "cmov" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" + [[package]] name = "cobs" version = "0.3.0" @@ -1581,6 +1637,12 @@ dependencies = [ "windows-core", ] +[[package]] +name = "cpubits" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae" + [[package]] name = "cpufeatures" version = "0.3.1" @@ -1696,7 +1758,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d045de693cb712d0b22c6a64be5b953f67b3ce00ab5ad3dd5d8b441886ab8e1a" dependencies = [ "quote", - "syn 2.0.119", + "syn 3.0.6", +] + +[[package]] +name = "ctutils" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261af4dc7a06ea8a527a8717d8cbba3417530d6ea14e1edb3de6b67806be474f" +dependencies = [ + "cmov", ] [[package]] @@ -1951,6 +2022,7 @@ dependencies = [ "block-buffer", "const-oid 0.10.2", "crypto-common", + "ctutils", ] [[package]] @@ -3162,6 +3234,24 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5491a308e0214554f07a81d8944abe45f552871c12e3c3c6e7e5d354039a6c4c" +[[package]] +name = "hkdf" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4aaa26c720c68b866f2c96ef5c1264b3e6f473fe5d4ce61cd44bbe913e553018" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f" +dependencies = [ + "digest", +] + [[package]] name = "html-escape" version = "0.2.15" @@ -3634,6 +3724,16 @@ dependencies = [ "libc", ] +[[package]] +name = "inout" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a580c13f0ffc335ef42dd3f6b1a41b726051c5e1656d9a3aa6fddb3c5dfbbf9" +dependencies = [ + "block-padding", + "hybrid-array", +] + [[package]] name = "inventory" version = "0.3.25" @@ -3848,6 +3948,15 @@ dependencies = [ "serde", ] +[[package]] +name = "keyring-core" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29fbf4b551298c67925f38cf341a1ada797a75f1837bdf8ae1fc8e2ebc6efb59" +dependencies = [ + "log", +] + [[package]] name = "khronos-egl" version = "6.0.0" @@ -4663,6 +4772,7 @@ name = "moq-studio" version = "0.1.0" dependencies = [ "anyhow", + "apple-native-keyring-store", "ashpd 0.13.13", "bytes", "eframe", @@ -4673,7 +4783,9 @@ dependencies = [ "global-hotkey", "hang", "humantime", + "humantime-serde", "image", + "keyring-core", "kio", "moq-audio", "moq-auth", @@ -4689,10 +4801,12 @@ dependencies = [ "mp4-atom", "objc2-app-kit 0.3.2", "pipewire", + "png 0.18.1", "pollster 1.0.1", "qrcodegen", "raw-window-handle", "resvg 0.50.0", + "rfd", "rune-fx", "same-file", "serde", @@ -4703,9 +4817,11 @@ dependencies = [ "url", "usage-rs", "wgpu", + "windows-native-keyring-store", "windows-sys 0.61.2", "winit", "x11rb 0.13.2", + "zbus-secret-service-keyring-store", ] [[package]] @@ -5238,10 +5354,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" dependencies = [ "bitflags 2.13.2", + "block2 0.6.2", "objc2 0.6.5", "objc2-core-foundation", "objc2-core-graphics", "objc2-foundation 0.3.2", + "objc2-uniform-type-identifiers 0.3.2", ] [[package]] @@ -6732,6 +6850,34 @@ dependencies = [ "mpeg4-audio-const", ] +[[package]] +name = "rfd" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4b9d4857b10297ffb0f64cae711e983a7aeaee561848d56d429d3858bd8ed93" +dependencies = [ + "block2 0.6.2", + "dispatch2", + "js-sys", + "libc", + "log", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "objc2-uniform-type-identifiers 0.3.2", + "percent-encoding", + "pollster 1.0.1", + "raw-window-handle", + "wasm-bindgen", + "wasm-bindgen-futures", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "web-sys", + "windows-sys 0.61.2", +] + [[package]] name = "rgb" version = "0.8.53" @@ -7143,6 +7289,25 @@ dependencies = [ "libc", ] +[[package]] +name = "secret-service" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5107b24b91445dd2aa449a258a1807b63240942157292354dc5bfdbeb8bc6db8" +dependencies = [ + "aes", + "cbc", + "futures-util", + "getrandom 0.4.3", + "hkdf", + "hybrid-array", + "num", + "once_cell", + "serde", + "sha2", + "zbus 5.19.0", +] + [[package]] name = "security-framework" version = "3.7.0" @@ -7354,6 +7519,17 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d" +[[package]] +name = "sha2" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -9713,6 +9889,18 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" +[[package]] +name = "windows-native-keyring-store" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063426e76fdec7438d56bb777f67e318a84a25c707b07e575cb8b78e10c028f8" +dependencies = [ + "byteorder", + "keyring-core", + "windows-sys 0.61.2", + "zeroize", +] + [[package]] name = "windows-numerics" version = "0.3.1" @@ -10178,6 +10366,17 @@ dependencies = [ "zvariant", ] +[[package]] +name = "zbus-secret-service-keyring-store" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74801d001b9e7729adb4f1825b67b398185fed424749aa3d8bacf70417137d9a" +dependencies = [ + "keyring-core", + "secret-service", + "zbus 5.19.0", +] + [[package]] name = "zbus_macros" version = "5.19.0" diff --git a/README.md b/README.md index f52efa50..6254857b 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,11 @@ Flatpak bundle for x86_64 and aarch64: ```bash flatpak install --user moq-studio-x86_64.flatpak -flatpak run live.kixel.studio show.toml --connect https://cdn.moq.dev/anon --broadcast my-show +flatpak run live.kixel.studio ``` -Its menu entry opens the scene collection kept in the app's own data -directory and saves recordings to your Videos folder. The sandbox reaches +Its menu entry opens [your shows](#your-shows) and saves recordings to your +Videos folder. The sandbox reaches cameras through the camera portal, which asks once, and files under your home directory. The virtual camera is its PipeWire node only, since the sandbox has no `/dev/video*`. @@ -25,31 +25,37 @@ submodule: ```bash git clone --recurse-submodules https://github.com/moq-dev/studio cd studio -cargo run --release -p moq-studio --features capture,openh264 -- \ - show.toml --connect https://cdn.moq.dev/anon --broadcast my-show +cargo run --release -p moq-studio --features capture,openh264 ``` -- `show.toml` is the scene collection. If it does not exist yet, - [guided setup](#first-launch) proposes one and creates it. Changes are saved - to it a second after you stop editing, with no save step. -- `--recordings ` is where recordings are saved, by default beside - `show.toml`. -- Without `--connect`, the studio composes, previews, and records but - publishes nothing, and broadcast sources stay offline. -- `--failover ` publishes the same broadcast to a second relay under the +- With no arguments, the window opens on [your shows](#your-shows). Name a + show to open it at once: `moq-studio show.toml`. A show is its scene file; + if it does not exist yet, [guided setup](#first-launch) proposes one and + creates it. Changes are saved to it a second after you stop editing, with + no save step. +- Nothing is published until you [go live](#going-live) from the window, and + you end the stream from it too. Until then the studio composes, previews, + and records, and broadcast sources and guests play through the show's + relays. +- Where a show streams is in Settings, Stream (see + [Stream settings](#stream-settings)), kept beside the show. A flag sets one + for a single run, over the show's own, and is never saved: `--connect` (the + relay) with `--connect-token`, `--failover`, `--broadcast`, `--on-demand`, + `--recordings ` (by default beside the show), and the guest flags. +- A failover relay publishes the same broadcast to a second relay under the same broadcast instance, so a viewer linked to both resumes mid-group from it when the first fails. Both relays must speak the one `--connect-version`, which must carry instances (`moq-lite-07-wip` today, which a relay - accepts only when configured to), or the studio refuses to start; it also + accepts only when configured to), or going live with both refuses; it also refuses a fixed `--connect-bind` port, since each relay's connection binds - its own. Its credential rides its URL's `?jwt=`; `--connect-token` goes to - the first relay only. The stream's tracks claim their bitrate on the first + its own. Each relay's token is its own: `--connect-token` goes to the + `--connect` relay only. The stream's tracks claim their bitrate on the first relay's link alone, so only that link is probed toward the stream's rate, and the video follows that link's estimate alone. -- Quitting while live ends every track after its last pictures and sound, - then closes each relay session once the relay has them, waiting up to about - a second, so viewers and recordings on the relay see the broadcast end - rather than cut off. +- Quitting while live ends the stream as **END STREAM** does: every track + ends after its last pictures and sound, then each relay session closes once + the relay has them, waiting up to about a second, so viewers and recordings + on the relay see the broadcast end rather than cut off. - `capture` adds camera, display, window, microphone, and system-audio sources, and listening to an audio scene. On Linux it links ALSA; add `pipewire` for PipeWire cameras and the [virtual camera](#virtual-camera)'s PipeWire node. @@ -72,10 +78,21 @@ cargo run --release -p moq-studio --features capture,openh264 -- \ - `moq-studio --watch ` opens no scene file and plays a studio broadcast instead, as a viewer sees it; see [Watching](#watching). +## Your shows + +Opened with no show, the window lists the shows you have opened, the latest +first, each with the last picture of its program, its shape, and when it was +last live and for how long. Click one to pick up where it ended; nothing goes +live until you say so. **New show** asks where to keep a new show's file and +starts [guided setup](#first-launch) there, and **Open a show file** opens +any other. Right-click a show to forget it; one whose file has moved says so. +The list and the pictures are yours, kept with the app's settings rather than +beside any show, and a show's picture is saved as the window closes. + ## First launch -Opening a scene file that does not exist yet starts guided setup instead of -the studio. It runs three checks, and a check that fails shows its reason: +Opening a show whose scene file does not exist yet starts guided setup instead +of the studio. It runs three checks, and a check that fails shows its reason: - **Devices:** the cameras, displays, and audio inputs this machine has. - **Encoders:** for each canvas setup can propose (1080p and 720p at 60 or 30 @@ -84,12 +101,13 @@ the studio. It runs three checks, and a check that fails shows its reason: short burst of moving frames. An encoder keeps up when a frame takes at most three quarters of the frame period, leaving the rest for sources and the compositor. -- **Uplink:** with `--connect`, setup publishes a probe at the `--broadcast` - path for about six seconds and subscribes to it through the relay, so the - relay pulls it. The congestion controller's send-rate estimate is the - measurement. With `--failover`, only the `--connect` relay is measured, - since only its link is probed toward the stream's rate. A connection that - reports no estimate, such as WebSocket, fails the check. +- **Uplink:** with a relay, from `--connect` or the show's stream settings, + setup publishes a probe at the broadcast's path for about six seconds and + subscribes to it through the relay, so the relay pulls it. The congestion + controller's send-rate estimate is the measurement. With a failover relay, + only the first is measured, since only its link is probed toward the + stream's rate. A connection that reports no estimate, such as WebSocket, + fails the check. Setup then proposes a scene named Main and a canvas, explaining each choice. The scene has the first display filling the canvas, the first camera in the @@ -107,17 +125,18 @@ canvas and no sources. The proposed scene is the first edit in the history, so undoing it leaves that empty scene. Setup writes an ordinary scene file. Change its sources and scenes on the -BUILD page, and its canvas in Settings. The health dot shows how the uplink -holds up once you are live. +BUILD page, its canvas in Settings, and where it streams in Settings, Stream. +The health dot shows how the uplink holds up once you are live. -Setup sits in the desktop's own window frame, and the studio then draws its -own (see [The window](#the-window)). On macOS the system's title bar stays +Your shows and setup sit in the desktop's own window frame, and the studio +then draws its own (see [The window](#the-window)). On macOS the system's title bar stays until the next launch. ## The window -The studio opens to its **LIVE** page: the program in a blue tally frame, as -large as the window allows. The title bar and the strip along the bottom stay +The studio opens to its **LIVE** page: the program as large as the window +allows, in a neutral frame tagged **OFF AIR** until you go live, then a blue +one tagged **ON AIR**. The title bar and the strip along the bottom stay on every page, so the scenes, the sound, and the panic key never leave the window while you are on air. @@ -134,22 +153,24 @@ macOS the system's buttons and edges stay. It holds, from the left: file**, **Copy the selected item**, and **Paste**. - Undo and redo, each naming under the pointer the edit it would step. - The pages: **LIVE**, **BUILD**, **MIX**, and **REVIEW**. -- The health dot, the stream's worst grade at a glance. Click it for each - relay, who is watching, the encoder, and each problem, and **Details** for - the [Health](#health) window. It reads **Not live** without `--connect`. +- The health dot, the stream's worst grade at a glance. Click it for the + worst problem first, then each destination, who is watching, and the + encoder, and **Details** for the [Health](#health) window. Off air it reads + **Ready** once the show has a relay, and **No relay** until then. - Record, which starts or stops a [recording](#recording) with REVIEW's picks. Its dot pulses while recording, and says for how long under the pointer. -- The live control: **LIVE** and how long the studio has been live, with - `--connect`, or **NOT LIVE** without it. The studio goes live at launch, - so it starts and ends nothing yet. +- The live control: **GO LIVE** off air, which opens the + [go-live sheet](#going-live); on air, **LIVE** and how long the stream has + run, which reads **END STREAM** under the pointer. - The gear, which opens [Settings](#settings). - Minimize, maximize, and close, except on macOS. The **strip** holds: - A **pad** for each scene, its picture redrawn a few times a second, with its - name, its hotkey, and an ON AIR tag on the scene on program. Click a pad to + name, its hotkey, and an ON AIR tag on the scene on program; off air, the + scene on program is tagged **FIRST** in amber, the one the stream opens on. Click a pad to take its scene on air by the show's transition (see [Transitions](#transitions)); taking the scene already on air does nothing. A scene that cannot go on air, of another size or showing the program, has @@ -205,12 +226,61 @@ A message about what the last action did shows over the bottom of the page for a few seconds, an error a little longer. A conflict with an outside edit to the scene file, or a failed save, shows over its top until it is settled. +### Going live + +**GO LIVE** opens a sheet that says which scene the stream opens on, then: + +- **Where it goes:** the show's relay and its failover relay, each with a + switch and its state, such as *Connected, 18 ms away*. A relay switched off + is left out of this stream. +- **Checks**, filled in as they finish: whether each camera has a picture, + whether a microphone's level moves, whether the encoder keeps up with the + canvas (timed as [setup](#first-launch) times it), and whether the + connection to the first relay switched on carries what the stream sends + (measured as setup measures it). A failed check is one sentence and its fix, + such as **Send 720p instead**, which changes the canvas, or **Check again**. +- **GO LIVE TO** the number of destinations switched on. A failed check never + stops you; only having none switched on does. + +Going live dials each relay, failing with why if none answers within 15 +seconds, then opens the program's encoders and announces its broadcast. Each +time on air is a broadcast of its own. On air, the live control is the clock; +under the pointer it reads **END STREAM**, and holding it down for a moment +ends the stream, handing the relays its tail first, as quitting does. The +**Go live** and **End stream** hotkeys do the same at once, going live to the +relays switched on without the sheet. + +Off air, the program has no past to replay, and a replay of it says so. + +### Stream settings + +Settings, Stream holds where the show streams, saved in `show.stream.toml` +beside `show.toml` rather than in it, since a scene file is meant to be +shared: + +- **Relay**, the one the stream goes to, and its **Token**. +- **Failover relay** and its token: a second relay the same broadcast goes + to, which needs one `--connect-version` with broadcast instances. +- **Broadcast name**, the path on the relays, `studio` until set. +- **On demand**, which encodes the canvas size only while someone watches + (see [Output](#output)). + +Tokens are kept in the system's credential store (the Secret Service on Linux, +the login keychain on macOS, the Credential Manager on Windows), one per relay +address, never in a file: a `?jwt=` typed into an address moves there when +saved. A setting a flag overrides for this run says so. A change applies the +next time you go live; a change to the room the guests join applies once the +show is opened again. The recordings folder and the guests' room are kept in +the same file, as `recordings`, `room`, `room_key`, `join_page`, and +`guest_expiry`, set there by hand until Settings has panes for them. + ### Settings | Tab | Use it to | | --- | --- | | Show | Set the canvas size and frame rate and each scene's size, see the broadcast path, whether the program is encoding, the encoder sessions open, and the encoder work of the program, the recording, and each published scene, and turn the virtual camera of the program or of each published scene on. | -| Hotkeys | Bind keys to the panic key, replay, save a clip, start or stop recording, and take each scene, and clear them (see [Hotkeys](#hotkeys)). | +| Stream | Set the relay, its token, the failover relay, the broadcast's name, and on demand (see [Stream settings](#stream-settings)). | +| Hotkeys | Bind keys to the panic key, replay, save a clip, start or stop recording, go live, end the stream, and take each scene, and clear them (see [Hotkeys](#hotkeys)). | | Effects | Pick how the window's [effects](#effects) move. | | Graph | See the sources, scenes, and audio scenes as nodes, wired left to right to what draws or holds them, and wire them there (see [Scene graph](#scene-graph)). | | History | See every edit, and undo or redo back to any of them. | @@ -243,9 +313,9 @@ scene of the program's size goes on program: its pad refuses another, saying why, and an edit resizing the scene on air is refused. Tick **Publish** on a scene in the Scenes panel to put it live as a broadcast -of its own beneath the program's, at `<--broadcast>/`, at its own -size, with renditions and encoders of its own (see [Output](#output)). A -published scene is always live and never switched: it shows what its items +of its own beneath the program's, at `/`, at its own +size, with renditions and encoders of its own (see [Output](#output)), while +the program is on air. A published scene is never switched: it shows what its items show, whatever is on program. For a portrait stream that follows the program, publish a portrait scene drawing the program through a program source (see [Scene sources](#scene-sources)), with any overlay of its own placed beside @@ -259,7 +329,7 @@ does not publish while live. A source captures or decodes once however many scenes show it. A published scene is drawn only while one of its encoders takes the frame, so with -`--on-demand`, or without a relay, one nobody watches costs no drawing. An +on demand, or off air, one nobody watches costs no drawing. An item's keyframes play in a published scene from when it was published, picked for recording, or the studio started, whichever came first: a recording and a broadcast of one scene share one picture. @@ -369,8 +439,9 @@ comes along, renamed if its name is taken. Copied filters paste onto the selected source or item, after its own. The clipboard holds text in the scene file's format. -A broadcast source subscribes through the same relay connections. It plays its -broadcast through the first relay while that relay has a route to it, and +A broadcast source subscribes through the show's relays, on air or off, +over sessions of their own that only subscribe. It plays its broadcast +through the first relay while that relay has a route to it, and through the failover otherwise, so a publisher restarted behind only the failover replaces the first relay's copy once that copy ends. It plays the best video and audio its catalog lists, switches when the catalog changes, and @@ -575,9 +646,12 @@ moq-studio show.toml --connect 'https://relay.example.com/show?jwt=...' \ --room guests --room-key room.jwk --join-page https://join.example.com/ ``` -- `--room` is a path under the `--connect` URL's, here `show/guests` on the +The guest flags set the room for one run; `room`, `room_key`, `join_page`, and +`guest_expiry` in the show's [stream settings](#stream-settings) file keep it. + +- `--room` is a path under the relay's URL, here `show/guests` on the relay. The studio's own token must let it subscribe there. A guest's browser - dials the same relay, so `--connect` must be `https://`, or `http://` only to + dials the same relay, so it must be `https://`, or `http://` only to this machine or the local network. - `--room-key` signs each guest's token. The studio refuses a key whose scope reaches outside the room, so a stolen key cannot sign for the rest of the @@ -602,13 +676,13 @@ moq-studio show.toml --connect 'https://relay.example.com/show?jwt=...' \ Links from before let their holder subscribe to the whole room, renewals included, so they must die with the old key, and a relay keeps a session it already admitted until its token expires. -- With `--failover`, a link still names only the `--connect` relay: the join +- With a failover relay, a link still names only the first relay: the join page dials one relay, and a guest's token is rooted at the room there, so guests drop while that relay is down. The studio follows the room through both relays, like any broadcast source, so a guest the failover routes at the same path, as a relay in the same cluster does, keeps reaching it. Anyone the failover lets publish in the room joins as a guest, so guard the - room there as on the `--connect` relay. + room there as on the first relay. **Invite** in the Guests panel makes a link for one guest name and shows it as a QR code; **Copy link** puts it on the clipboard instead. The guest's token is @@ -767,7 +841,7 @@ items = [ [[scenes]] name = "Portrait" size = { width = 1080, height = 1920 } # its own size; the program's without one -published = true # live at <--broadcast>/Portrait +published = true # live at /Portrait recorded = true # recordings hold this scene rather than the program items = [ { source = "on-air", rect = { x = 0, y = 0, width = 1080, height = 1920 }, crop = { left = 0.34, right = 0.34 } }, @@ -901,8 +975,9 @@ before sharing. The program publishes as two H.264 renditions, at the canvas size and at half of it, at the canvas frame rate, with the audio scene on program as Opus stereo audio, -under the `--broadcast` path. A canvas under 360 lines has no half size. Each -published scene publishes the same way at `<--broadcast>/`, at +under the broadcast's path, while on air. A canvas under 360 lines has no +half size. Each published scene publishes the same way at +`/`, at its own size and half of it, its tracks sharing the connection's bandwidth with the program's, and its own encode of the audio scene it carries. Timestamps come from the studio's own clock, so a source that stalls repeats @@ -923,12 +998,11 @@ renditions' tracks end and new ones are listed in their place in a catalog update, on the same timeline, and viewers switch to them; the video pauses while the new encoders open. Items keep their place in canvas pixels. A canvas the encoder cannot take stops the video, saying why, until the canvas changes -again. At startup, it stops the studio when live; without `--connect`, the -studio starts without video. +again. Going live with one fails, saying why. The canvas size encodes whether or not anyone watches, so a viewer who arrives late can fetch the recent past. The half size encodes only while someone -watches it. `--on-demand` copies and encodes the canvas size only while someone +watches it. On demand copies and encodes the canvas size only while someone watches it too, which saves that work but leaves nothing from before the first viewer; audio encodes either way. A recording has an encoder of its own (see Recording). A hardware encoder that reads @@ -977,7 +1051,7 @@ encode engine for them all. Settings' Show tab counts the sessions open: | Encoder | Sessions | |---|---| -| The program's canvas size, live | 1, or none without `--connect` | +| The program's canvas size | 1 while on air | | Its half size | 1 while someone watches it | | Each published scene's own size and half size | as the program's | | The recording's own size | 1 while recording | @@ -991,7 +1065,7 @@ encodes on hardware, so do the sources, and a session the GPU refuses fails that source's track with the encoder's reason in the Sources panel rather than falling back to software. The source keeps drawing in the studio's own scenes. The program opens its session before any -source, even with `--on-demand`, so the sources past the cap fail rather than +source, even with on demand, so the sources past the cap fail rather than the program; so does each scene published in the scene file at startup. A scene published later, past the cap, publishes without video and says why in Settings' Show tab. When the program encodes in software, a source takes hardware @@ -1128,7 +1202,7 @@ the relay serves, so a recording starts and stops without touching the live stream. The audio scene it holds is encoded a second time for it while recording: the one on program, so the file holds what viewers hear, or the one REVIEW picks, which viewers never -can. Without `--connect`, only the +can. Off air, only the recording's encoder encodes the program. Each file plays while it grows, so a crash leaves a playable fragmented MP4, @@ -1166,8 +1240,8 @@ a WebGL page runs slower. ## Hotkeys The Hotkeys tab in Settings binds a key to the **Panic** key, **Replay**, -**Save clip**, starting or stopping a recording, and taking each scene, as its -pad does. Press **Bind**, then the key with any modifiers; Escape, or leaving +**Save clip**, starting or stopping a recording, **Go live**, **End stream**, +and taking each scene, as its pad does. Press **Bind**, then the key with any modifiers; Escape, or leaving the window or the tab, cancels. Every action starts unbound, so no key a game uses is taken unasked, and a key bound to one action is refused for another until it is cleared there. Replay, Save clip, and a recording use REVIEW's @@ -1253,8 +1327,9 @@ Nothing records in the background for this. The program's tracks keep their last 30 seconds for late viewers anyway, and each source's track while it is on program (a picture shown in a scene on air, or a sound played by the audio scene on program) or recorded, and a replay copies from those, so a replay -goes back at most that far. A replay of the program needs `--connect`; a local -source keeps its track without a relay. With `--on-demand`, the program has +goes back at most that far. A replay of the program needs it on air, and +reaches back no further than going live; a local source keeps its track off +air. With on demand, the program has no past from before someone watched it, and a source has none from before it was last on program or recorded; a replay of nothing is refused, saying why. A broadcast source replays from what the studio received of it, and only over a diff --git a/packaging/flatpak/live.kixel.studio.yml b/packaging/flatpak/live.kixel.studio.yml index d69bcfba..7f448c2f 100644 --- a/packaging/flatpak/live.kixel.studio.yml +++ b/packaging/flatpak/live.kixel.studio.yml @@ -23,6 +23,8 @@ finish-args: - --filesystem=xdg-run/pipewire-0 # Scene files, image sources, and recordings wherever the creator keeps them. - --filesystem=home + # Relay tokens, kept in the Secret Service (GNOME Keyring, KWallet). + - --talk-name=org.freedesktop.secrets modules: - name: moq-studio buildsystem: simple diff --git a/packaging/flatpak/moq-studio-desktop.sh b/packaging/flatpak/moq-studio-desktop.sh index 8362c3c8..b6af47d0 100755 --- a/packaging/flatpak/moq-studio-desktop.sh +++ b/packaging/flatpak/moq-studio-desktop.sh @@ -1,6 +1,5 @@ #!/bin/sh -# The menu entry's launch, which passes no arguments: the scene collection in -# the app's own data directory, so the first launch runs guided setup, and -# recordings in the Videos folder rather than beside it. +# The menu entry's launch, which passes no arguments: the library of recent +# shows, and recordings in the Videos folder rather than beside each show. set -eu -exec moq-studio --recordings "$(xdg-user-dir VIDEOS)" "$XDG_DATA_HOME/scenes.toml" "$@" +exec moq-studio --recordings "$(xdg-user-dir VIDEOS)" "$@" diff --git a/packaging/flatpak/smoke.sh b/packaging/flatpak/smoke.sh index f4d41fb1..8db56105 100755 --- a/packaging/flatpak/smoke.sh +++ b/packaging/flatpak/smoke.sh @@ -64,7 +64,10 @@ SWAYSOCK=$(compgen -G "$runtime/sway-ipc.*.sock") WAYLAND_DISPLAY=$(basename "$(compgen -G "$runtime/wayland-*[0-9]")") export SWAYSOCK WAYLAND_DISPLAY -flatpak run --env=NO_COLOR=1 --command=moq-studio-desktop live.kixel.studio 2>"$log" & +# A show that does not exist yet, so the launch runs guided setup rather than +# opening the library. +# shellcheck disable=SC2016 # Expanded inside the sandbox. +flatpak run --env=NO_COLOR=1 --command=sh live.kixel.studio -c 'exec moq-studio-desktop "$XDG_DATA_HOME/smoke.toml"' 2>"$log" & studio=$! pids+=("$studio") diff --git a/quest/m0/destinations.md b/quest/m0/destinations.md index 02b63aff..2176be9f 100644 --- a/quest/m0/destinations.md +++ b/quest/m0/destinations.md @@ -74,13 +74,12 @@ Decided 2026-11-09 (maintainer, /quest-audit): Changed 2026-11-09 (maintainer, /quest-plan): going live and stopping, as actions and as hotkeys, are -[Going live from inside the app](/quest/m0/ux/go-live.md), which lands them -for MoQ relays. This quest adds its destinations to that sheet rather than +the go-live sheet and live control the studio has, which land them for MoQ +relays. This quest adds its destinations to that sheet rather than building a second way to start a stream. ## Required -- [Going live from inside the app](/quest/m0/ux/go-live.md) - the go-live sheet, the live control, and the health list its destinations join - [moq's egress dial changes are pinned](/quest/m0/pin-egress-dial.md) - RTMPS that keeps `tcUrl`, and a dial policy the caller supplies ## Related diff --git a/quest/m0/ux/first-run.md b/quest/m0/ux/first-run.md index f6535e5f..1983f146 100644 --- a/quest/m0/ux/first-run.md +++ b/quest/m0/ux/first-run.md @@ -44,4 +44,3 @@ machine with a real camera and microphone, watched without helping. ## Required - [Adding a source by picking a picture](/quest/m0/ux/add.md) - the cards with live pictures and meters -- [Going live from inside the app](/quest/m0/ux/go-live.md) - the show library it starts from and the relay it measures diff --git a/quest/m0/ux/go-live.md b/quest/m0/ux/go-live.md deleted file mode 100644 index 3de8b878..00000000 --- a/quest/m0/ux/go-live.md +++ /dev/null @@ -1,74 +0,0 @@ -# [L] Going live from inside the app - -## Goal - -`moq-studio` starts with no arguments and no terminal, and a broadcaster goes -live and stops from the window, as in -[`mock/golive.html`](/quest/m0/ux/mock/golive.html): - -- **Opened with no show**, it lists recent shows with a picture of each, a - New show card, and Open a show file. -- **Off air**, the frame around the picture is neutral, the tag reads OFF - AIR, and the live control is GO LIVE. -- **GO LIVE** opens a short sheet: where the stream is going, each - destination with a toggle and its state, and a checklist that fills in - (camera, a microphone level that moves, an encoder that keeps up, a - connection that carries the bitrate), then one confirm. A failed line is - one plain sentence and its fix. -- **On air**, the control is the clock, and END STREAM under the pointer, - held to confirm. Ending delivers the broadcast's tail before the session - closes, as quitting does today. -- **The health dot** opens every destination, the viewers, and the encoder, - and its details: the worst problem first, in plain words with its cause, - which is today's Health panel. - -Where the stream goes is set in Settings: the relay's address, its token, a -failover relay, the broadcast's name, and whether to encode only while -someone watches. Go live and End stream are hotkey actions. - -## Plan - -Today the studio is live from launch when `--connect` is given and never -otherwise, and the relay, token, broadcast name, failover, on-demand, and -recordings folder are flags (`rs/moq-studio/src/main.rs`). A packaged app is -opened by a double click, so none of that can stay a flag only. - -- ✅ **Connecting is a runtime action.** The engine opens and closes its - relay sessions on Go live and End stream. Composing, previewing, and - recording never needed a relay and still do not. -- **Flags stay** as overrides for scripts and tests: a flag wins over the - saved setting for that run and is never written back. -- **Where it is saved:** the relay address, broadcast name, and options are - per show, beside the scene file, not in it, since the scene file is meant - to be shared and names no relay. Tokens go in the operating system's - credential store, as [destinations](/quest/m0/destinations.md) decided for - stream keys, and never in a file. -- **The checklist is guided setup's probes** (`rs/moq-studio/src/setup.rs`): - devices, the encoder's pace, and the uplink. The uplink probe runs against - the relay about to be used and is skipped with its reason when a - connection reports no estimate. -- Recommended, not decided: a failed check never blocks going live. Its - sentence and its fix are advice, since a streamer on a bad connection may - still choose to go. Only having nothing to send, no destination switched - on, disables the confirm. -- GO LIVE is not in the accent, which stays the on-air state, nor red, which - is errors alone. -- **A replay of the program** needs the relay's cache, so off air it says so - rather than failing. -- **Recent shows** are kept per user. A show's picture is the last frame of - its program, saved on quit. -- Guests' room flags move with the rest; the room key stays a file the - setting points at. - -[Destinations](/quest/m0/destinations.md) adds RTMP and WHIP rows to the same -sheet and the same health popover; this quest lands them for MoQ relays -alone. - -Human check: a real stream to a real relay with the maintainer's token, -ended and started again; the credential store's own prompt on each desktop; -and opening the app from a file manager with no terminal. - -## Related - -- [Destinations](/quest/m0/destinations.md) - RTMP and WHIP rows in this sheet -- [Packaging](/quest/m0/packaging/README.md) - an app opened by a double click has no flags diff --git a/quest/m0/ux/settings.md b/quest/m0/ux/settings.md index e1694e76..74f958f5 100644 --- a/quest/m0/ux/settings.md +++ b/quest/m0/ux/settings.md @@ -9,8 +9,8 @@ title bar's gear, as in - **Show:** landscape or portrait, the canvas size and frame rate as a few named choices with the numbers behind Custom, and per-scene sizes behind a disclosure. -- **Stream:** the relay, failover, and options from - [go live](/quest/m0/ux/go-live.md). +- **Stream:** the relay, its token, the failover, the broadcast's name, and + on demand, as today's Stream tab holds them in `.stream.toml`. - **Recording:** the folder, what a recording holds, and each source too. - **Hotkeys:** today's Hotkeys panel, on keycaps. - **Guests:** the room, its key, the join page, and how long a link lasts. @@ -43,7 +43,3 @@ bar. Human check: whether each setting is where a streamer would look for it, and the words on each pane. - -## Required - -- [Going live from inside the app](/quest/m0/ux/go-live.md) - the Stream pane's settings and where they are saved diff --git a/quest/m1/dual-format.md b/quest/m1/dual-format.md index 69905d61..97b82ebd 100644 --- a/quest/m1/dual-format.md +++ b/quest/m1/dual-format.md @@ -37,4 +37,3 @@ Human check: a phone and a desktop viewer watching the same show. ## Required - [The BUILD page](/quest/m0/ux/build.md) - editing an arrangement per format -- [Going live from inside the app](/quest/m0/ux/go-live.md) - a format per destination diff --git a/quest/m1/obs-import.md b/quest/m1/obs-import.md index 56ef4d9e..989513e3 100644 --- a/quest/m1/obs-import.md +++ b/quest/m1/obs-import.md @@ -35,5 +35,4 @@ twenty scenes to try a new tool. ## Required -- [Going live from inside the app](/quest/m0/ux/go-live.md) - the show library it opens from - [Adding a source by picking a picture](/quest/m0/ux/add.md) - where a missing device is picked again diff --git a/quest/m2/phone-remote.md b/quest/m2/phone-remote.md index ec0c4360..a8cd578f 100644 --- a/quest/m2/phone-remote.md +++ b/quest/m2/phone-remote.md @@ -21,7 +21,3 @@ Planned 2026-11-09 (maintainer, /quest-plan), and held for later: ✅ m2 - Removing a remote stops renewing its token, as for a guest. - The page follows the look of the studio's LIVE page ([mock-up](/quest/m0/ux/mock/shell-live.webp)) at a phone's width. - -## Required - -- [Going live from inside the app](/quest/m0/ux/go-live.md) - the relay and room it is reached through diff --git a/rs/moq-studio/Cargo.toml b/rs/moq-studio/Cargo.toml index 4d1fc279..ca771025 100644 --- a/rs/moq-studio/Cargo.toml +++ b/rs/moq-studio/Cargo.toml @@ -57,6 +57,11 @@ hang = { workspace = true } # Stamps a recording's file name with when it started. Already in the graph # through moq-scene's humantime-serde. humantime = { workspace = true } +# How long a guest's link lasts, as the stream settings file spells it. +humantime-serde = { workspace = true } +# The relay tokens, in the operating system's credential store rather than a +# file; each platform's store is its own crate, below. +keyring-core = "1.0" kio = { workspace = true, features = ["async", "runtime"] } moq-audio = { workspace = true, features = ["bus"] } # Signs guest tokens with the room key. @@ -68,9 +73,14 @@ moq-scene = { workspace = true } moq-stats = { workspace = true, features = ["async"] } moq-tokio = { workspace = true, default-features = false, features = ["net"] } moq-video = { workspace = true } +# A show's picture in the library, the last frame of its program. +png = "0.18" pollster = { workspace = true } # The join link's QR code. No dependencies of its own. qrcodegen = "1.8" +# The system's own dialog for opening a show file or saving a new one: the +# desktop portal on Linux, so it works in the Flatpak. +rfd = "0.18" # Whether a recording's marker is still the file its holder locked, which std # cannot tell on Windows. same-file = "1.0.6" @@ -109,6 +119,9 @@ raw-window-handle = "0.6" # Hotkeys on X11, grabbed by keycode so any key binds on any layout. `xkb` # tells a held key's repeats from new presses. x11rb = { version = "0.13", features = ["xkb"] } +# Relay tokens in the Secret Service (GNOME Keyring, KWallet), over the D-Bus +# stack ashpd uses, on tokio as ashpd has it, with no system library. +zbus-secret-service-keyring-store = { version = "1.0", features = ["rt-tokio-crypto-rust"] } [target.'cfg(any(target_os = "macos", windows))'.dependencies] # System-wide hotkeys on macOS and Windows; X11 grabs keys itself, and Wayland @@ -119,12 +132,17 @@ global-hotkey = "0.9" # Whether the system asks apps to reduce motion, for the effects. eframe's # version, already in the graph through winit. objc2-app-kit = { version = "0.3", default-features = false, features = ["std", "NSAccessibility", "NSWorkspace"] } +# Relay tokens in the login keychain. +apple-native-keyring-store = { version = "1.0", features = ["keychain"] } [target.'cfg(windows)'.dependencies] # Which virtual key the foreground window's layout puts on each key, so a # hotkey registers the key pressed, and whether the system asks apps to # reduce motion, for the effects. windows-sys = { version = "0.61", features = ["Win32_UI_Input_KeyboardAndMouse", "Win32_UI_WindowsAndMessaging"] } +# Relay tokens in the Windows Credential Manager. Without `search`, which the +# studio never does, so no regex. +windows-native-keyring-store = { version = "1.1", default-features = false } [build-dependencies] # Rasterizes the app icon's SVG for the window. No text or embedded images, so diff --git a/rs/moq-studio/assets/icons/check.svg b/rs/moq-studio/assets/icons/check.svg new file mode 100644 index 00000000..6252adfd --- /dev/null +++ b/rs/moq-studio/assets/icons/check.svg @@ -0,0 +1,14 @@ + + + + diff --git a/rs/moq-studio/assets/icons/cpu.svg b/rs/moq-studio/assets/icons/cpu.svg new file mode 100644 index 00000000..f17efb08 --- /dev/null +++ b/rs/moq-studio/assets/icons/cpu.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + diff --git a/rs/moq-studio/assets/icons/folder-open.svg b/rs/moq-studio/assets/icons/folder-open.svg new file mode 100644 index 00000000..96c91c2d --- /dev/null +++ b/rs/moq-studio/assets/icons/folder-open.svg @@ -0,0 +1,14 @@ + + + + diff --git a/rs/moq-studio/assets/icons/rectangle-horizontal.svg b/rs/moq-studio/assets/icons/rectangle-horizontal.svg new file mode 100644 index 00000000..a6f23595 --- /dev/null +++ b/rs/moq-studio/assets/icons/rectangle-horizontal.svg @@ -0,0 +1,14 @@ + + + + diff --git a/rs/moq-studio/assets/icons/rectangle-vertical.svg b/rs/moq-studio/assets/icons/rectangle-vertical.svg new file mode 100644 index 00000000..375b91b9 --- /dev/null +++ b/rs/moq-studio/assets/icons/rectangle-vertical.svg @@ -0,0 +1,14 @@ + + + + diff --git a/rs/moq-studio/assets/icons/triangle-alert.svg b/rs/moq-studio/assets/icons/triangle-alert.svg new file mode 100644 index 00000000..ddfe1ab7 --- /dev/null +++ b/rs/moq-studio/assets/icons/triangle-alert.svg @@ -0,0 +1,16 @@ + + + + + + diff --git a/rs/moq-studio/assets/icons/upload.svg b/rs/moq-studio/assets/icons/upload.svg new file mode 100644 index 00000000..270074cb --- /dev/null +++ b/rs/moq-studio/assets/icons/upload.svg @@ -0,0 +1,16 @@ + + + + + + diff --git a/rs/moq-studio/src/controls.rs b/rs/moq-studio/src/controls.rs index e5a316ad..c8305665 100644 --- a/rs/moq-studio/src/controls.rs +++ b/rs/moq-studio/src/controls.rs @@ -1,7 +1,7 @@ //! What the operator does from a button or a hotkey: take a scene, panic, -//! replay, save a clip, and record. Hotkeys fire from outside the window's -//! frames, so a key pressed while a game has focus acts at once, even while -//! the window is hidden and draws nothing. +//! replay, save a clip, record, and go live and end the stream. Hotkeys fire +//! from outside the window's frames, so a key pressed while a game has focus +//! acts at once, even while the window is hidden and draws nothing. use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex}; @@ -9,8 +9,9 @@ use std::sync::{Arc, Mutex}; use anyhow::Context; use moq_scene::Source; -use crate::engine::{Engine, State}; +use crate::engine::{Engine, OnAir, State}; use crate::replay; +use crate::stream::{Stream, Switched}; /// Something a hotkey can be bound to. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] @@ -32,11 +33,22 @@ pub enum Action { Record, /// Cut to the safe scene and mute every microphone and guest. Panic, + /// Go live to the relays switched on, skipping the go-live sheet's checks. + GoLive, + /// End the stream, handing the relays its tail first. + EndStream, } impl Action { /// The actions every scene file has, as the Hotkeys panel lists them. - pub const FIXED: [Self; 4] = [Self::Panic, Self::Replay, Self::SaveClip, Self::Record]; + pub const FIXED: [Self; 6] = [ + Self::Panic, + Self::Replay, + Self::SaveClip, + Self::Record, + Self::GoLive, + Self::EndStream, + ]; /// Whether a key can be bound to it: a fixed action, or a scene. pub fn offered(&self) -> bool { @@ -54,6 +66,8 @@ impl std::fmt::Display for Action { Self::SaveClip => write!(f, "Save clip"), Self::Record => write!(f, "Start or stop recording"), Self::Panic => write!(f, "Panic"), + Self::GoLive => write!(f, "Go live"), + Self::EndStream => write!(f, "End stream"), } } } @@ -62,6 +76,13 @@ impl std::fmt::Display for Action { pub struct Controls { pub engine: Arc, runtime: tokio::runtime::Handle, + /// Where the show streams, as Settings edits it. + pub stream: Mutex, + /// Which relays going live sends to, as the go-live sheet switches them. + pub switched: Mutex, + /// Why the last go-live failed, until the go-live sheet or the status bar + /// shows it. + pub refused: Mutex>, /// The Replay panel's picks, which a replay or clip from a hotkey takes too. pub replay: Mutex, /// Whether the next recording gives each source a file of its own too. @@ -94,10 +115,13 @@ impl Default for Replay { } impl Controls { - pub fn new(engine: Arc, runtime: tokio::runtime::Handle) -> Self { + pub fn new(engine: Arc, stream: Stream, runtime: tokio::runtime::Handle) -> Self { Self { engine, runtime, + stream: Mutex::new(stream), + switched: Mutex::default(), + refused: Mutex::default(), replay: Mutex::default(), record_sources: AtomicBool::new(false), fired: Arc::default(), @@ -105,7 +129,7 @@ impl Controls { } /// Do `action`, saying what it did. - pub fn fire(&self, action: &Action) -> anyhow::Result { + pub fn fire(self: &Arc, action: &Action) -> anyhow::Result { match action { Action::Cut => { let mut state = self.engine.state.lock().unwrap(); @@ -136,11 +160,58 @@ impl Controls { } } } + Action::GoLive => self.go_live(), + Action::EndStream => self.end_stream(), } } + /// Go live to the relays switched on, in the background: reading their + /// tokens blocks on the credential store, and dialing them takes a while. + /// How it went shows in the status bar, and a refusal in the go-live + /// sheet too. + pub fn go_live(self: &Arc) -> anyhow::Result { + anyhow::ensure!( + self.engine.on_air() == OnAir::Off, + "the program is already on air, or on its way on or off" + ); + *self.refused.lock().unwrap() = None; + let controls = self.clone(); + std::thread::Builder::new() + .name("go live".into()) + .spawn(move || { + // Each relay's client binds its socket on the runtime. + let _runtime = controls.runtime.enter(); + let switched = *controls.switched.lock().unwrap(); + let destination = controls.stream.lock().unwrap().clone().destination(switched); + let result = destination.and_then(|destination| { + let to = destination.broadcast.clone(); + controls.runtime.block_on(controls.engine.go_live(destination))?; + Ok(format!("live as {to}")) + }); + let result = result.map_err(|err| format!("{err:#}")); + if let Err(err) = &result { + *controls.refused.lock().unwrap() = Some(err.clone()); + } + controls.report(&Action::GoLive, result); + }) + .context("cannot go live")?; + Ok("going live".into()) + } + + /// End the stream in the background, handing the relays its tail first. + pub fn end_stream(self: &Arc) -> anyhow::Result { + anyhow::ensure!(self.engine.on_air().live().is_some(), "the program is not on air"); + let controls = self.clone(); + self.runtime.spawn(async move { + let result = controls.engine.end_stream().await; + let result = result.map(|()| "the stream ended".to_string()); + controls.report(&Action::EndStream, result.map_err(|err| format!("{err:#}"))); + }); + Ok("ending the stream".into()) + } + /// Do `action` for a hotkey, keeping how it went for the status bar. - pub fn press(&self, action: &Action) { + pub fn press(self: &Arc, action: &Action) { match action { Action::Replay => drop(self.replay(true, true)), Action::SaveClip => drop(self.replay(false, true)), diff --git a/rs/moq-studio/src/engine.rs b/rs/moq-studio/src/engine.rs index a3c0c2d3..14ed9498 100644 --- a/rs/moq-studio/src/engine.rs +++ b/rs/moq-studio/src/engine.rs @@ -1,10 +1,11 @@ //! Everything behind the window: the GPU, the sources, the program clock that -//! draws the canvas and mixes the audio, and the broadcast it encodes into: -//! the program, at the canvas size and at half of it ([`crate::ladder`]), and -//! each published scene's beneath it, at its own size and half. The relays -//! serve those broadcasts, and recordings read the program or a scene. Each local source's own -//! track stays in a broadcast of the studio's own, which recordings read too, -//! as they read each broadcast source from the relays. +//! draws the canvas and mixes the audio, and, while on air ([`air`]), the +//! broadcast it encodes into: the program, at the canvas size and at half of +//! it ([`crate::ladder`]), and each published scene's beneath it, at its own +//! size and half. The relays serve those broadcasts, and recordings read the +//! program or a scene, on air or not. Each local source's own track stays in +//! a broadcast of the studio's own, which recordings read too, as they read +//! each broadcast source from the relays. //! //! Threads: //! - **program** draws preview, program, and each published scene once per @@ -12,11 +13,10 @@ //! encode, scaled to the rendition and stamped with the program clock. //! - **audio** advances the audio bus, and with it each audio scene's mix, on //! the same clock. -//! - **audio-encode** encodes the audio scene on program into the program -//! audio, and **audio-record** the one recordings hold into the recording -//! broadcast's own audio while a recording reads it. -//! - Each published scene's audio, and each guest's return feed, a -//! mix-minus, encodes on the tokio runtime. +//! - **audio-record** encodes the audio scene recordings hold into the +//! recording broadcast's own audio while a recording reads it. +//! - While on air, the program audio, each published scene's, and each +//! guest's return feed, a mix-minus, encode on the tokio runtime. //! - **encode**: one per program rendition, which waits for each program copy //! and encodes it. A new canvas size or frame rate starts new renditions. //! - Recordings write their files on the tokio runtime. @@ -49,6 +49,10 @@ use crate::autosave::{self, Autosave}; use crate::ladder::{self, Gate, Joins, Step}; use crate::{health, mix, record}; +pub mod air; + +pub use air::{Destination, OnAir}; + /// The GPU everything shares: sources upload to it, the compositor draws on /// it, the window presents from it, and the encoder reads the program from it. #[derive(Clone)] @@ -697,41 +701,6 @@ impl Stats { } } -/// The relays the program goes live on. -pub struct Output { - /// The broadcast path on the relays. - pub path: String, - /// Whether the program video's canvas size is copied and encoded only - /// while someone watches it, rather than all the time. The half size - /// always is. - pub on_demand: bool, - /// A connection to each relay, which reconnects on its own and dials only - /// while held. The Health panel reads their states. - connections: Vec, - /// The client that dialed each, whose endpoint sends the last close. - clients: Vec, -} - -impl Output { - /// Close each relay session once the relay has received what it was sent - /// of every finished track, which the session bounds at about a second, - /// then each client's endpoint, so the relay hears the close rather than - /// waiting out an idle timeout. A track still live is cut. - async fn close(&self) { - let mut closing = tokio::task::JoinSet::new(); - for (connection, client) in self.connections.iter().zip(&self.clients) { - let (connection, client) = (connection.clone(), client.clone()); - closing.spawn(async move { - if let Err(err) = connection.close().await { - tracing::warn!(%err, "the relay session closed without draining"); - } - client.close().await; - }); - } - closing.join_all().await; - } -} - /// A relay the program is published to. #[derive(Clone)] pub struct Relay { @@ -739,23 +708,20 @@ pub struct Relay { pub url: url::Url, } -/// The program's broadcast, open for as long as the engine runs. +/// What the program's broadcasts share for as long as the engine runs, on air +/// or not: the clock, the local sources' tracks, and the recording's own +/// broadcast. pub struct Program { - /// Where the broadcast is announced, which the relay connections publish. - _origin: moq_net::origin::Producer, - publication: moq_net::origin::Route, - /// What the broadcast lists and the clock its timestamps are on, for a - /// replay of the program or a source. - catalog: moq_scene::publish::Catalog, + /// What every catalog's timestamps are on: the recording's, the program's + /// each time it goes live, and each published scene's. clock: moq_mux::Clock, + /// Where the program clock started on [`clock`](Self::clock). + epoch: Duration, /// Where the local sources keep their own tracks, on the same clock. sources: moq_scene::publish::Publish, - /// The sources published independently, whose tracks the broadcast + /// The sources published independently, whose tracks the broadcast on air /// carries beside the program's. published: tokio::sync::watch::Sender>, - /// Where and when the broadcast's viewers show those sources, while any - /// is published. - layout: Mutex, /// What a recording reads the program from, on the same clock. recording: moq_net::origin::Route, /// The recording broadcast's catalog, held for as long as the engine runs, @@ -764,48 +730,14 @@ pub struct Program { /// The origin the studio's own broadcasts are read through, which no relay /// connection carries. local: moq_net::origin::Producer, - /// The audio's claim on the connection's bandwidth, which it does not - /// follow: Opus at this rate is never what congests the uplink. - _audio: bandwidth::Reservation, -} - -impl Drop for Program { - fn drop(&mut self) { - self.publication.broadcast().close(); - } } impl Program { - /// End the layer layout, then finish the program's catalog and the - /// recording's, once every track they list has ended, so a viewer or a - /// recording reading either reaches its end rather than a cut. + /// Finish the recording's catalog, once every track it lists has ended, so + /// a recording reading it reaches its end rather than a cut. fn finish(&self) { - if let Err(err) = self.layout.lock().unwrap().finish() { - tracing::warn!(%err, "cannot finish the layer layout"); - } - for catalog in [&self.catalog, &self.recorded] { - // Fails only once the catalog failed, which ended its tracks already. - let _ = catalog.clone().finish(); - } - } - - /// What a replay of the program could copy: its video at each size, - /// largest first, with its audio, up to now. - pub fn program(&self) -> Vec { - let catalog = self.catalog.snapshot(); - let audio = catalog.audio.renditions.into_iter().next(); - let mut video: Vec<_> = catalog.video.renditions.into_iter().collect(); - video.sort_by_key(|(_, config)| { - let pixels = u64::from(config.coded_width.unwrap_or(0)) * u64::from(config.coded_height.unwrap_or(0)); - std::cmp::Reverse(pixels) - }); - match video.is_empty() { - true => vec![self.target(None, audio)], - false => video - .into_iter() - .map(|video| self.target(Some(video), audio.clone())) - .collect(), - } + // Fails only once the catalog failed, which ended its tracks already. + let _ = self.recorded.clone().finish(); } /// What a replay of the local source `name` copies: the video or sound of @@ -826,19 +758,6 @@ impl Program { }) } - fn target( - &self, - video: Option<(String, hang::catalog::VideoConfig)>, - audio: Option<(String, hang::catalog::AudioConfig)>, - ) -> moq_scene::replay::Target { - moq_scene::replay::Target { - broadcast: self.publication.broadcast().consume(), - video, - audio, - end: self.clock.now(), - } - } - /// Encode the local sources' tracks on program, whether or not anything /// reads them, so a replay of one has its past: the pictures `shown` in a /// scene on air or a published or recorded scene drawn, and the sound the @@ -866,31 +785,6 @@ impl Program { self.sources .set_on_program(moq_scene::publish::OnProgram { shown, heard }); } - - /// Publish the layer layout of what `state` drew on program at `at` on - /// the media clock, while any source is published independently. - fn lay_out(&self, state: &State, at: Duration) { - // Past what a timestamp holds, the frame goes unstamped too. - let Ok(stamp) = moq_net::Timestamp::try_from(at) else { - return; - }; - let collection = &state.collection; - let mut publisher = self.layout.lock().unwrap(); - let published = match collection.published.is_empty() { - true => publisher.finish(), - false => { - // To the whole microsecond as the frame's stamp is, rather than - // rounded as the wire would, so a cut's layout starts on its frame. - let start = at.saturating_sub(state.compositor.program_since()).as_micros(); - let start = Duration::from_micros(start as u64); - let layout = moq_scene::layout::Layout::new(collection, state.compositor.program_scene(), start); - publisher.update(layout, stamp) - } - }; - if let Err(err) = published { - tracing::warn!(%err, "cannot publish the layer layout"); - } - } } /// The running studio. @@ -902,24 +796,38 @@ pub struct Engine { pub stats: Arc, /// How the stream is delivered, graded every [`health::INTERVAL`]. pub health: Mutex, + /// What grades it: the stream on air's delivery, or only the studio's + /// own work while off air. + sampler: Mutex, /// The audio scene the program audio carries, as the collection picks it. program_audio: mix::Pick, /// The audio scene recordings hold, as the collection picks it. recorded_audio: mix::Pick, /// Plays an audio scene to the speakers while the creator listens. monitor: Mutex>, - /// `None` when running without a relay. - pub output: Option, + /// The stream, while on air, going live, or ending. + air: Mutex, + /// Whether the program is on air, for the window and for quitting, which + /// waits out a stream going live or ending. + on_air: tokio::sync::watch::Sender, + /// What the program clock takes from going live and gives back on ending. + handoff: Mutex, + /// The program's broadcast on air, which guests' return feeds show. + on_air_program: tokio::sync::watch::Sender>, /// Records the program, and each source too if asked. pub recorder: record::Recorder, /// The room guests join, when configured. pub room: Option>, /// Each guest's return feed, once the studio's session in the room dials. feeds: Mutex>, - /// The program's broadcast. + /// What the program's broadcasts share, on air or not. pub program: Program, - /// Keeps broadcast sources' origin open when no connection holds it. - _origin: Option, + /// Where broadcast sources, guests, and viewers' reports arrive from the + /// relays the studio [watches](Self::watch), open even while none is. + subscribe: moq_net::origin::Producer, + /// A session to each relay set for the show, which only subscribes, so + /// broadcast sources and guests are seen off air too. + watching: Mutex>, /// Set by [`stop`](Self::stop), which ends the program clock. stopped: AtomicBool, /// The program clock's and the audio's threads, which [`stop`](Self::stop) @@ -946,12 +854,6 @@ const CLOSE: Duration = Duration::from_secs(3); #[derive(Clone)] pub struct Launch { pub gpu: Gpu, - /// The relays to publish to, the preferred first; none publishes nothing. - pub relays: Vec, - /// The broadcast path the program is published at. - pub broadcast: String, - /// Whether the program video encodes only while someone watches. - pub on_demand: bool, /// The directory recordings are saved in. pub recordings: PathBuf, /// The room guests join, if any. @@ -961,23 +863,13 @@ pub struct Launch { impl Engine { /// Open the `loaded` collection and history on `launch.gpu`, start the /// program clock, and save both to `autosave`'s files as they change, - /// starting at once. - /// The program is encoded into a broadcast at `launch.broadcast` while - /// anyone wants it: a recording into `launch.recordings`, or every one of - /// `launch.relays`, preferred first, which want it all the time unless - /// `launch.on_demand`. The guests who join `launch.room` are added as - /// sources. + /// starting at once. Recordings go into `launch.recordings`, and the + /// guests who join `launch.room` are added as sources. Nothing is + /// published until the studio [goes live](Self::go_live). /// /// Call inside the tokio runtime that serves the relay connections. pub async fn start(launch: Launch, autosave: Autosave, loaded: autosave::Loaded) -> anyhow::Result> { - let Launch { - gpu, - relays, - broadcast, - on_demand, - recordings, - room, - } = launch; + let Launch { gpu, recordings, room } = launch; let (bus, driver) = moq_audio::bus::Bus::new(Default::default())?; let subscribe = moq_tokio::origin::spawn(); // Every relay feeds `subscribe`, so a guest either one routes is seen. @@ -999,26 +891,10 @@ impl Engine { let canvas = collection.canvas; let stats = Arc::new(Stats::default()); - let path = - moq_net::Path::new(broadcast.as_str()).with_context(|| format!("cannot publish at `{broadcast}`"))?; - let origin = moq_tokio::origin::spawn(); - let (live, subscribe) = if relays.is_empty() { - (None, Some(subscribe)) - } else { - tracing::info!(broadcast = %path, "publishing"); - let reports = subscribe.consume(); - let clients = relays.iter().map(|relay| relay.client.clone()).collect(); - let (connections, links) = connect(relays, &origin, &subscribe); - let live = Live { - connections, - clients, - links, - reports, - on_demand, - }; - (Some(live), None) - }; - let (program, publish) = publish(&gpu, &stats, origin, &path, canvas, live.as_ref()).await?; + // The program clock's start, from which the audio clock advances the + // bus too, so the sources place their sound on it. + let start = Instant::now(); + let (program, publish) = publish(&gpu, &stats, canvas, start).await?; // Nothing in either local broadcast refers to another. let local = |broadcast: moq_net::broadcast::Consumer| moq_mux::Source::new(program.local.consume(), broadcast); let inputs = record::Inputs { @@ -1027,19 +903,10 @@ impl Engine { origin: sources.clone(), }; let recorder = record::Recorder::new(inputs, &recordings, autosave.path())?; - let output = live.map(|live| Output { - path: path.to_string(), - on_demand, - connections: live.connections, - clients: live.clients, - }); // Absolute, so a copied image names the same file in another collection. let dir = autosave.path().parent().filter(|dir| !dir.as_os_str().is_empty()); let dir = std::path::absolute(dir.unwrap_or(Path::new(".")))?; - // The program clock's start, from which the audio clock advances the - // bus too, so the sources place their sound on it. - let start = Instant::now(); let (mixer, mixed) = source::Mixer::new(driver, start); let sources = Sources::new(source::Context { bus: bus.clone(), @@ -1060,6 +927,7 @@ impl Engine { compositor.set_preview(first.map(|scene| scene.name.clone())); compositor.cut(&collection, &sources)?; + let epoch = program.epoch; let engine = Arc::new(Self { gpu, state: Mutex::new(State { @@ -1078,65 +946,43 @@ impl Engine { autosave, stats, health: Mutex::default(), + sampler: Mutex::new(health::Sampler::new(None)), program_audio: mix::Pick::default(), recorded_audio: mix::Pick::default(), monitor: Mutex::default(), - output, + air: Mutex::new(air::Slot::Off), + on_air: tokio::sync::watch::Sender::new(OnAir::Off), + handoff: Mutex::default(), + on_air_program: tokio::sync::watch::Sender::new(None), recorder, room, feeds: Mutex::default(), program, - _origin: subscribe, + subscribe, + watching: Mutex::default(), stopped: AtomicBool::new(false), threads: Mutex::default(), running: Mutex::default(), }); let Publish { - renditions, - ladder, recording, - mut extras, - audio, recorded_audio, - clock, - health, sources: _, } = publish; - // Where the program clock starts on the catalog's, so the wall time the - // catalog advertises for a frame is when the program drew it. - let epoch = Duration::from(clock.capture(start)?); - extras.epoch = epoch; if let Some(room) = &engine.room && let Some(origin) = room.origin() { - let program = engine.program.publication.broadcast().consume(); - let feeds = crate::feed::Feeds::new(room.clone(), origin.clone(), program, clock.clone(), epoch)?; + let program = engine.on_air_program.subscribe(); + let clock = engine.program.clock.clone(); + let feeds = crate::feed::Feeds::new(room.clone(), origin.clone(), program, clock, epoch)?; *engine.feeds.lock().unwrap() = Some(feeds); } - let main = Line::new(renditions, canvas, ladder, true); - // Opened before the program clock starts the sources, as the - // program's encoder is, so each holds its encode session first. - let mut lines = Lines::new(); - let (published, recorded): (Vec<(String, Canvas)>, Canvas) = { - let state = engine.state.lock().unwrap(); - (published(state.collection()), recorded(state.collection()).1) - }; - // Probed now too, so a scene a recording cannot encode says so before - // anyone records it. It opens its session only once recorded. + // Probed now, so a scene a recording cannot encode says so before + // anyone records it, and opened before the program clock starts the + // sources. It opens its session only once recorded. + let (_, recorded) = recorded(engine.state.lock().unwrap().collection()); let recording = Line::open(recording, recorded).await; - for (name, canvas) in published { - let video = Arc::new(VideoStats::default()); - engine - .stats - .published - .lock() - .unwrap() - .insert(name.clone(), video.clone()); - let opened = extras.open(&name, canvas, video.clone()).await; - let opened = opened.inspect_err(|err| video.fail(format!("{err:#}"))).ok(); - lines.insert(name, opened); - } // Each worker holds the engine, so one that cannot start stops those // already running, which would otherwise keep this engine and its // publication alive beside a retry's. @@ -1150,37 +996,22 @@ impl Engine { let thread = clocked("audio".into(), async move || mix.run_audio(start, config, mixer).await)?; engine.threads.lock().unwrap().push(thread); let program = engine.clone(); - let encoders = Encoders { - main, - recording, - extras, - lines, - }; let thread = clocked("program".into(), async move || { - program.run_program(start, epoch, encoders).await + program.run_program(start, epoch, recording).await + })?; + engine.threads.lock().unwrap().push(thread); + // On its own thread, so an encoder that falls behind skips its own + // audio rather than holding up the bus. + let encode = engine.clone(); + let follow = engine.recorded_audio.follow(); + let thread = clocked("audio-record".into(), async move || { + encode.encode_audio(epoch, rate, follow, recorded_audio).await })?; engine.threads.lock().unwrap().push(thread); - // Each on its own thread, so an encoder that falls behind skips its own - // audio rather than holding up the bus or the other. - let audio = [ - ("audio-encode", Audio::Program(audio), engine.program_audio.follow()), - ( - "audio-record", - Audio::Recording(recorded_audio), - engine.recorded_audio.follow(), - ), - ]; - for (name, audio, follow) in audio { - let encode = engine.clone(); - let thread = clocked(name.into(), async move || { - encode.encode_audio(epoch, rate, follow, audio).await - })?; - engine.threads.lock().unwrap().push(thread); - } let save = engine.clone(); clocked("autosave".into(), async move || save.autosave.run(&save.state).await)?; starting.started(); - tokio::spawn(engine.clone().grade(health::Sampler::new(health))); + tokio::spawn(engine.clone().grade()); // Last, once nothing can fail: a start that fails is retried from setup, // and a follower already running would keep this engine and its // publication alive beside the retry's. @@ -1207,12 +1038,12 @@ impl Engine { /// every picture, to publish the copies on their way to it and what it /// still holds, and to end its video track, so quitting loses none of the /// program's last pictures; a published scene's catalog then finishes too. - /// The program audio ends its track too, and then the program's catalog - /// and the recording's finish, so a viewer or a recording reading the - /// program reaches the end of each. Then stop every source, which - /// finishes its own track on its thread, and the browser sources' helper, - /// waiting for it to exit, so their profile is saved and free for the next - /// launch. + /// The audio ends its tracks too, and then the recording's catalog + /// finishes, so a recording reading the program reaches its end. Then stop + /// every source, which finishes its own track on its thread, and the + /// browser sources' helper, waiting for it to exit, so their profile is + /// saved and free for the next launch. A stream on air ends with + /// [`close`](Self::close). pub fn stop(&self) { self.stopped.store(true, Ordering::Relaxed); let threads = std::mem::take(&mut *self.threads.lock().unwrap()); @@ -1234,11 +1065,13 @@ impl Engine { } } - /// Once [`stop`](Self::stop) has ended the tracks of every picture, close + /// Once [`stop`](Self::stop) has ended the tracks of every picture, end + /// the stream on air as [`end_stream`](Self::end_stream) does, closing /// each relay session once the relay has their tails, so a viewer or a - /// recording on the relay receives them rather than a cut. Meanwhile wait - /// for each source's thread to end, having finished its own track, and then - /// finish the sources' local catalog. Bounded at [`CLOSE`]. + /// recording on the relay receives them rather than a cut; one going live + /// or ending is waited out first. Meanwhile wait for each source's thread + /// to end, having finished its own track, and then finish the sources' + /// local catalog. Bounded at [`CLOSE`]. pub async fn close(&self) { let running = std::mem::take(&mut *self.running.lock().unwrap()); let sources = async { @@ -1251,9 +1084,15 @@ impl Engine { let _ = self.program.sources.finish(); }; let relays = async { - if let Some(output) = &self.output { - output.close().await; + let mut on_air = self.on_air.subscribe(); + // Fails only once the engine is gone, which holds the sender. + let _ = on_air + .wait_for(|on_air| !matches!(on_air, OnAir::Starting | OnAir::Ending)) + .await; + if let Err(err) = self.end_stream().await { + tracing::debug!(error = format!("{err:#}"), "nothing on air to end"); } + self.unwatch().await; }; // A source's track is in the studio's own local broadcast, which no // relay session carries, so neither waits on the other. @@ -1342,12 +1181,13 @@ impl Engine { } /// Grade the stream's health every interval, for the Health panel. - async fn grade(self: Arc, mut sampler: health::Sampler) { + async fn grade(self: Arc) { let mut interval = kio::clock::interval(health::INTERVAL); interval.set_missed_tick_behavior(kio::clock::MissedTickBehavior::Skip); loop { let now = interval.tick().await; - let report = sampler.sample(now, self.local(now)); + let local = self.local(now); + let report = self.sampler.lock().unwrap().sample(now, local); *self.health.lock().unwrap() = report; } } @@ -1504,34 +1344,30 @@ impl Engine { /// Draw the program and each published scene once per tick of the program /// clock, and hand each to its renditions' encoders, stamped `epoch` past - /// `start`, while their gates let them encode: the full size every frame - /// while live and not on demand, otherwise only while anyone watches it, - /// and the half size only while anyone watches it. The program, or the - /// scene recordings hold, goes to the recording's own encoder too, which - /// encodes only while recording. + /// `start`, while their gates let them encode. On air, that is the full + /// size every frame unless on demand, otherwise only while anyone watches + /// it, and the half size only while anyone watches it; off air, the + /// program and the published scenes encode nothing. The program, or the + /// scene recordings hold, goes to `recording`, the recording's own + /// encoder, which encodes only while recording. /// /// A published or recorded scene is drawn only while one of its encoders /// or virtual camera takes the frame, so one nobody reads costs no - /// drawing. See [`Encoders`] for what encodes each. Drawing outlives the - /// encoders: a failed output stops copying its picture, and the scenes - /// keep moving. Each virtual camera on takes every frame of what it shows - /// while an app reads it, and one whose scene is no longer published - /// turns off. + /// drawing. Drawing outlives the encoders: a failed output stops copying + /// its picture, and the scenes keep moving. Each virtual camera on takes + /// every frame of what it shows while an app reads it, and one whose + /// scene is no longer published turns off. /// /// Runs until the studio [stops](Self::stop), and returns once every /// rendition's encode thread has finished its track. - async fn run_program(&self, start: Instant, epoch: Duration, encoders: Encoders) { - let Encoders { - mut main, - mut recording, - extras, - mut lines, - } = encoders; + async fn run_program(&self, start: Instant, epoch: Duration, mut recording: Line) { let mut framerate = self.state.lock().unwrap().compositor.canvas().framerate; let mut clock = program_clock(start, framerate); // The encoders of lines since ended, waited on as the studio stops so // each finishes its track. let mut retired: Vec = Vec::new(); + // The encoders of the stream on air. + let mut air: Option = None; loop { let tick = clock.tick().await; @@ -1539,22 +1375,41 @@ impl Engine { // is let go, so the UI does not wait on their backends. let mut closed: Vec = Vec::new(); if self.stopped.load(Ordering::Relaxed) { + // A stream handed over since is ended too, and one asked to end + // finds nothing left to wait for. + let (start, _end) = self.handoff.lock().unwrap().close(); // Without a sender, each encoder publishes what it was sent and // still holds, then finishes its track. - retired.push(main.end(None)); retired.push(recording.end(None)); - retired.extend( - lines - .into_values() - .flatten() - .map(|(line, broadcast)| line.end(Some(broadcast))), - ); + let mut layouts = Vec::new(); + for lines in air.take().into_iter().chain(start) { + let ending = lines.end(); + retired.extend(ending.ended); + layouts.extend(ending.layout); + } for ended in retired { ended.join(); } + // Once the video it lays out has ended. + for mut layout in layouts { + air::finish_layout(&mut layout); + } return; } retired.retain(|ended| !ended.is_finished()); + // Ended before another starts, so the two never hold encode sessions + // at once. + let (starting, end) = self.handoff.lock().unwrap().take(); + if let Some(reply) = end { + let ending = air.take().map(air::Lines::end).unwrap_or_default(); + if let Err(ending) = reply.send(ending) { + retired.extend(ending.ended); + } + self.stats.published.lock().unwrap().clear(); + } + if let Some(starting) = starting { + air = Some(starting); + } // Where this frame lands on the media clock. let at = epoch + tick.saturating_duration_since(start); let drawn = { @@ -1573,37 +1428,42 @@ impl Engine { self.pick_audio(state); } - // Each published scene's line starts once it is published, in a - // broadcast of its own, and ends once it no longer is. + // On air, each published scene's line starts once it is + // published, in a broadcast of its own, and ends once it no + // longer is. let published = published(&state.collection); - let gone: Vec = lines - .keys() - .filter(|line| !published.iter().any(|(name, _)| name == *line)) - .cloned() - .collect(); - for name in gone { - if let Some(Some((line, broadcast))) = lines.remove(&name) { - retired.push(line.end(Some(broadcast))); + if let Some(air) = &mut air { + let gone: Vec = air + .lines + .keys() + .filter(|line| !published.iter().any(|(name, _)| name == *line)) + .cloned() + .collect(); + for name in gone { + if let Some(Some((line, broadcast))) = air.lines.remove(&name) { + retired.push(line.end(Some(broadcast))); + } + self.stats.published.lock().unwrap().remove(&name); } - self.stats.published.lock().unwrap().remove(&name); - } - for (name, canvas) in &published { - let started = !lines.contains_key(name); - let line = lines.entry(name.clone()).or_insert_with(|| { - let video = Arc::new(VideoStats::default()); - self.stats.published.lock().unwrap().insert(name.clone(), video.clone()); - extras - .start(name, *canvas, video.clone()) - .inspect_err(|err| video.fail(format!("{err:#}"))) - .ok() - }); - // Its audio follows the audio scene it carries from now on. - if (synced || started) - && let Some((_, broadcast)) = line - && let Some(audio) = state.collection.published_audio(name) - && let Some(mix) = state.sources.mix(audio) - { - broadcast.audio.set(mix.clone()); + for (name, canvas) in &published { + let started = !air.lines.contains_key(name); + let extras = &air.extras; + let line = air.lines.entry(name.clone()).or_insert_with(|| { + let video = Arc::new(VideoStats::default()); + self.stats.published.lock().unwrap().insert(name.clone(), video.clone()); + extras + .start(name, *canvas, video.clone()) + .inspect_err(|err| video.fail(format!("{err:#}"))) + .ok() + }); + // Its audio follows the audio scene it carries from now on. + if (synced || started) + && let Some((_, broadcast)) = line + && let Some(audio) = state.collection.published_audio(name) + && let Some(mix) = state.sources.mix(audio) + { + broadcast.audio.set(mix.clone()); + } } } closed.extend( @@ -1618,8 +1478,9 @@ impl Engine { ); let (recorded, recorded_canvas) = recorded(&state.collection); let cameras = &state.cameras; + let lines = air.as_ref().map(|air| &air.lines); let wants = |name: &str| { - matches!(lines.get(name), Some(Some((line, _))) if line.wants()) + matches!(lines.and_then(|lines| lines.get(name)), Some(Some((line, _))) if line.wants()) || cameras .get(&Some(name.to_string())) .is_some_and(crate::vcam::Camera::wanted) @@ -1642,7 +1503,9 @@ impl Engine { continue; } self.program.on_program(state, shown); - self.program.lay_out(state, at); + if let Some(air) = &mut air { + air::lay_out(&mut air.layout, state, at); + } let compositor = &state.compositor; for (scene, camera) in &mut state.cameras { match scene { @@ -1684,17 +1547,18 @@ impl Engine { framerate = canvas.framerate; clock = program_clock(tick.saturating_add(period(framerate)), framerate); } - main.feed(Some(&program), canvas, timestamp); - let (texture, canvas) = drawn.recorded; - recording.feed(texture.as_ref(), canvas, timestamp); - for (name, texture, canvas) in drawn.published { - if let Some(Some((line, _))) = lines.get_mut(&name) { - line.feed(texture.as_ref(), canvas, timestamp); + let (texture, recorded) = drawn.recorded; + recording.feed(texture.as_ref(), recorded, timestamp); + if let Some(air) = &mut air { + air.main.feed(Some(&program), canvas, timestamp); + for (name, texture, canvas) in drawn.published { + if let Some(Some((line, _))) = air.lines.get_mut(&name) { + line.feed(texture.as_ref(), canvas, timestamp); + } } } } } - /// Advance the bus as the program clock advances, from `start`. /// /// Runs without a relay too, so the meters move and sources never back up, @@ -1726,32 +1590,31 @@ impl Engine { } } - /// Encode the mix `follow` reads into `audio`, stamped `epoch` past the - /// bus's start at `rate`, until the bus stops, and finish the track. + /// Encode the mix `follow` reads into the recording's own `audio`, stamped + /// `epoch` past the bus's start at `rate`, until the bus stops, and finish + /// the track. /// - /// The recording's audio encodes only while a recording reads it, and marks - /// the gap as the last one stops, so the next starts on the program clock - /// rather than where the samples left off. - async fn encode_audio(&self, epoch: Duration, rate: u32, mut follow: mix::Follow, audio: Audio) { - let (mut producer, recording) = match audio { - Audio::Program(producer) => (producer, false), - Audio::Recording(producer) => (producer, true), - }; - // The recording's audio failing leaves the published audio running, so - // it is the recording's to report. - let fail = |err: moq_audio::Error| match recording { - false => self.stats.fail_audio(err), - true => self.stats.fail_recording_audio(err), - }; + /// It encodes only while a recording reads it, and marks the gap as the + /// last one stops, so the next starts on the program clock rather than + /// where the samples left off. Its failing leaves the published audio + /// running, so it is the recording's to report. + async fn encode_audio( + &self, + epoch: Duration, + rate: u32, + mut follow: mix::Follow, + mut audio: moq_audio::encode::Producer, + ) { + let fail = |err: moq_audio::Error| self.stats.fail_recording_audio(err); let rate = u128::from(rate); let mut next = None; let mut wanted = false; while let Some(block) = follow.read().await { - let was = std::mem::replace(&mut wanted, !recording || producer.demand().wanted().is_some()); + let was = std::mem::replace(&mut wanted, audio.demand().wanted().is_some()); if !wanted { - if was && let Err(err) = producer.discontinuity() { + if was && let Err(err) = audio.discontinuity() { fail(err); - producer.abort(moq_net::StreamError::Internal.into()); + audio.abort(moq_net::StreamError::Internal.into()); return; } next = None; @@ -1760,7 +1623,7 @@ impl Engine { // Audio this encoder fell too far behind to read leaves a gap in // the track rather than pulling what follows early. if next.is_some_and(|next| next != block.position) { - producer.reanchor(); + audio.reanchor(); } next = Some(block.position + block.frames() as u64); let position = u128::from(block.position); @@ -1769,14 +1632,14 @@ impl Engine { continue; }; let data: Vec = block.data.iter().flat_map(|sample| sample.to_le_bytes()).collect(); - if let Err(err) = producer.write(&moq_audio::Frame::new(Bytes::from(data), timestamp)) { + if let Err(err) = audio.write(&moq_audio::Frame::new(Bytes::from(data), timestamp)) { fail(err); // Readers see the audio fail rather than go away unfinished. - producer.abort(moq_net::StreamError::Internal.into()); + audio.abort(moq_net::StreamError::Internal.into()); return; } } - if let Err(err) = producer.finish() { + if let Err(err) = audio.finish() { fail(err); } } @@ -1801,104 +1664,23 @@ impl Drop for Starting { } } -/// One encoder of a mix: the published program audio, or the recording -/// broadcast's own. -enum Audio { - Program(moq_audio::encode::Producer), - Recording(moq_audio::encode::Producer), -} - -/// The relay connections the program goes live on, the preferred first, and -/// the origin their viewers' reports and the relays' stats arrive on. -struct Live { - connections: Vec, - /// The client that dialed each connection. - clients: Vec, - links: Vec, - reports: moq_net::origin::Consumer, - /// The canvas size encodes only while someone watches it. - on_demand: bool, -} - -/// The encoders behind the program's broadcast, handed to their threads. +/// What starting the engine sets up for the program's broadcasts beside +/// [`Program`], handed to the threads that encode it. struct Publish { - /// Where the program video is published, a canvas at a time. - renditions: Renditions, - /// The renditions of the canvas the studio started with, unless the canvas - /// could not be encoded without a relay. - ladder: Option, /// Where the recording's own video goes, of the program or the scene it /// holds. recording: Renditions, - /// What publishes each published scene. - extras: Extras, - /// The program audio's encoder. - audio: moq_audio::encode::Producer, /// The recording broadcast's own audio encoder. recorded_audio: moq_audio::encode::Producer, - /// The catalog's clock, which the codec producers write timestamps - /// against verbatim. - clock: moq_mux::Clock, - /// What the health sampler grades, while live on a relay. - health: Option, /// Where each local source keeps its own track. sources: moq_scene::publish::Publish, } -/// Announce the program broadcast at `path` on `origin` under one instance, -/// which `live`'s relays publish when there are any. -async fn publish( - gpu: &Gpu, - stats: &Arc, - origin: moq_net::origin::Producer, - path: &moq_net::Path, - canvas: Canvas, - live: Option<&Live>, -) -> anyhow::Result<(Program, Publish)> { - let publication = origin - .route(path, moq_net::origin::RouteOptions::hidden()) - .context("cannot create the broadcast")?; - let mut broadcast = publication.broadcast().clone(); - // Each track reserves its ceiling on the first relay's estimate, which - // that connection then probes to fund: the bandwidth the stream is granted. - // An allocator spans one connection, so the failover's link is never - // probed. The catalog claims nothing itself, which would count each track - // twice. Without a relay nothing divides any bandwidth. - let bandwidth = match live { - Some(live) => live.connections[0].allocator(), - None => moq_net::bandwidth::Allocator::unlimited(), - }; - let catalog = moq_mux::catalog::Config::default().with_catalog(Default::default()); - let catalog = moq_scene::publish::Catalog::new(&mut broadcast, catalog)?; - let clock = catalog.clock(); - - // Probed now, so a machine that cannot encode the canvas fails at startup - // rather than once the program clock starts. Without a relay the studio - // still composes, previews, and records audio, and a new canvas tries again. - let probe = match Probe::new(gpu, canvas, false).await { - Ok(probe) => Some(probe), - Err(err) if live.is_none() => { - stats.video.fail(format!("{err:#}")); - None - } - Err(err) => return Err(err), - }; - // Sources take the program's tier: hardware when the program found it, so a - // session the GPU refuses fails that source loudly instead of falling to - // software. When the program could not use hardware, such as NVENC beside an - // integrated GPU it cannot read, a source may still reach it from the CPU. - let kind = match probe.as_ref().map(|probe| &probe.rungs[0].config.kind) { - Some(moq_video::encode::Kind::Named(name)) if name == "openh264" => moq_video::encode::Kind::Auto, - _ => moq_video::encode::Kind::Hardware, - }; - let sources = moq_scene::publish::Publish::new(clock.clone(), kind, stats.sessions.clone())?; - // Held until the video and audio are listed, so the first catalog carries - // both and any solicitation. - let reserved = catalog.reserve(); - // Viewers report back beneath the broadcast, which only a relay carries. - if live.is_some() { - health::solicit(&mut catalog.clone(), path)?; - } +/// Set up what the program's broadcasts share for as long as the engine runs: +/// the clock, with the program clock's `start` on it, the local sources' +/// tracks, and the recording's own broadcast, which reads the program at +/// `canvas` until a recording asks for another. +async fn publish(gpu: &Gpu, stats: &Arc, canvas: Canvas, start: Instant) -> anyhow::Result<(Program, Publish)> { // What a recording reads the program from: its own full-size encoder, of // the program or the scene it holds, at full quality whatever the grant, // and the mix it holds, in a broadcast no relay sees: announced on an @@ -1912,24 +1694,32 @@ async fn publish( .announce() .context("cannot announce the recording broadcast")?; let mut recorder = recording.broadcast().clone(); - let config = moq_mux::catalog::Config::default() - .with_catalog(Default::default()) - .with_clock(clock.clone()); + let config = moq_mux::catalog::Config::default().with_catalog(Default::default()); let recorded = moq_scene::publish::Catalog::new(&mut recorder, config)?; - let renditions = Renditions { - gpu: gpu.clone(), - broadcast: broadcast.clone(), - timebase: catalog.timebase(), - record: false, - bandwidth: bandwidth.clone(), - // Live on a relay and not on demand; otherwise only a viewer asks for - // the video. - on_demand: live.is_none_or(|live| live.on_demand), - live: live.is_some(), - stats: stats.clone(), - video: stats.video.clone(), - grants: String::new(), + // Every other catalog shares the recording's clock, so a recording, the + // program on air, and a source's track agree on when a frame was drawn. + let clock = recorded.clock(); + // Where the program clock starts on the catalog's, so the wall time the + // catalog advertises for a frame is when the program drew it. + let epoch = Duration::from(clock.capture(start)?); + + // Probed now, so a machine that cannot encode the canvas says so before + // going live, which tries it again. Sources take the program's tier: + // hardware when the program found it, so a session the GPU refuses fails + // that source loudly instead of falling to software. When the program could + // not use hardware, such as NVENC beside an integrated GPU it cannot read, a + // source may still reach it from the CPU. + let kind = match Probe::new(gpu, canvas, false).await { + Ok(probe) => match &probe.rungs[0].config.kind { + moq_video::encode::Kind::Named(name) if name == "openh264" => moq_video::encode::Kind::Auto, + _ => moq_video::encode::Kind::Hardware, + }, + Err(err) => { + stats.video.fail(format!("{err:#}")); + moq_video::encode::Kind::Hardware + } }; + let sources = moq_scene::publish::Publish::new(clock.clone(), kind, stats.sessions.clone())?; let recorded_video = Renditions { gpu: gpu.clone(), broadcast: recorder.clone(), @@ -1942,107 +1732,27 @@ async fn publish( video: stats.recording.clone(), grants: String::new(), }; - let ladder = match probe { - Some(probe) => { - let (ladder, opened) = renditions.start(probe)?; - // Before the program clock starts the sources, so the program holds - // its encode session even while unwatched. - match opened.await.context("the encode thread stopped")? { - Ok(()) => Some(ladder), - // Its encode thread reported why. - Err(_) if live.is_none() => None, - Err(err) => return Err(err), - } - } - None => None, - }; - let (input, options) = audio_options(); - let graded = catalog.clone(); - let listed = catalog.clone(); - let recorded_audio = moq_audio::encode::Producer::new(&mut recorder, recorded.clone(), input.clone(), &options)?; - let audio = moq_audio::encode::Producer::new(&mut broadcast, catalog, input, &options)?; - let audio_reservation = bandwidth.reserve(&audio.demand(), AUDIO_BITRATE); - stats - .grants - .lock() - .unwrap() - .insert(audio.track_name().to_string(), audio_reservation.consume()); - drop(reserved); - - // One instance on every relay, so a viewer moving between them resumes - // mid-group rather than restarting. - let instance = publication.instance(); - // Set once the program clock starts. - let epoch = Duration::ZERO; - publication.announce().context("cannot announce the broadcast")?; - - let (published, follow) = tokio::sync::watch::channel(BTreeSet::new()); - let forward = (sources.clone(), broadcast.clone(), listed.clone(), bandwidth.clone()); - tokio::spawn(async move { - let (sources, broadcast, catalog, bandwidth) = forward; - if let Err(err) = sources.forward(follow, broadcast, catalog, bandwidth).await { - tracing::warn!(%err, "stopped publishing sources independently"); - } - }); - let layout = Mutex::new(moq_scene::layout::Publisher::new(broadcast.clone(), listed.clone())); - - let health = match live { - Some(live) => { - let observer = hang::health::Observer::new(path.clone(), Some(instance.clone())); - Some(health::Publisher { - main: health::Broadcast::follow(observer, graded, &live.reports)?, - scenes: health::Scenes::new(live.reports.clone()), - clock: clock.clone(), - relays: live.links.clone(), - sources: sources.clone(), - }) - } - None => None, - }; - // Each published scene is graded beside the program, with its own viewers. - let graded = health.as_ref().map(|health| health.scenes.clone()); + let recorded_audio = moq_audio::encode::Producer::new(&mut recorder, recorded.clone(), input, &options)?; + let (published, _) = tokio::sync::watch::channel(BTreeSet::new()); Ok(( Program { - _origin: origin.clone(), - publication, - catalog: listed, - clock: clock.clone(), + clock, + epoch, sources: sources.clone(), published, - layout, recording, recorded, local, - _audio: audio_reservation, }, Publish { - extras: Extras { - origin: origin.clone(), - path: path.clone(), - clock: clock.clone(), - epoch, - runtime: tokio::runtime::Handle::current(), - gpu: gpu.clone(), - bandwidth, - on_demand: renditions.on_demand, - live: renditions.live, - stats: stats.clone(), - graded, - }, - renditions, - ladder, recording: recorded_video, - audio, recorded_audio, - clock, - health, sources, }, )) } - /// What the program audio, the recording's, and each published scene's encode: /// the bus's mix, as Opus at [`AUDIO_BITRATE`] on a track called `audio`. fn audio_options() -> (moq_audio::encode::Input, moq_audio::encode::Options) { @@ -2514,19 +2224,6 @@ struct Drawn { recorded: (Option, Canvas), } -/// What the program clock hands each picture to. -struct Encoders { - /// The program's. - main: Line, - /// The recording's own, fed the program or the scene recordings hold, - /// which a change of size probes for again as any line does. - recording: Line, - /// What starts the line of a scene published while the studio runs. - extras: Extras, - /// The published scenes' lines, those the studio started with first. - lines: Lines, -} - /// Each published scene in `collection`, with its canvas. fn published(collection: &Collection) -> Vec<(String, Canvas)> { let published = collection.scenes.iter().filter(|scene| scene.published); @@ -2599,16 +2296,6 @@ impl Extras { Ok((Line::new(renditions, canvas, None, false), broadcast)) } - /// [`start`](Self::start), opening the full size's encoder before - /// returning, as the program does at startup, so a scene published in the - /// scene file holds its encode session before any source opens one. A - /// scene whose encoder cannot open draws on without video, saying why in - /// `video`. - async fn open(&self, name: &str, canvas: Canvas, video: Arc) -> anyhow::Result<(Line, Broadcast)> { - let (renditions, broadcast) = self.publish(name, video)?; - Ok((Line::open(renditions, canvas).await, broadcast)) - } - /// Publish the scene `name` at its own path beneath the program's /// broadcast, with audio of its own, which encodes the audio scene it is /// [picked](Broadcast::audio) on the runtime, and where its video goes, @@ -2827,44 +2514,6 @@ fn period(framerate: u32) -> Duration { Duration::from_secs(1) / framerate } -/// Connect to every relay, publishing `origin` to each and feeding `subscribe` -/// the broadcast sources of each, and watch each connection for the Health -/// panel. -fn connect( - relays: Vec, - origin: &moq_net::origin::Producer, - subscribe: &moq_net::origin::Producer, -) -> (Vec, Vec) { - relays - .into_iter() - .enumerate() - .map(|(rank, Relay { client, url })| { - tracing::info!(url = %moq_tokio::RedactedUrl::new(&url), "connecting"); - // Only the scheme, host, and port: a path can carry a credential, and - // the panel may be on a shared screen. A URL without a host, such as - // a unix socket's, keeps its path, which is the address. - let endpoint = match url.host_str() { - Some(host) => match url.port() { - Some(port) => format!("{}://{host}:{port}", url.scheme()), - None => format!("{}://{host}", url.scheme()), - }, - None => format!("{}:{}", url.scheme(), url.path()), - }; - // The first relay's route to a broadcast source wins while it has - // one, whether it carries the same instance as the failover's or - // another. - let preference = match rank { - 0 => moq_net::origin::Preference::default(), - _ => moq_net::origin::Preference::new(-1), - }; - let sources = subscribe.clone().with_preference(preference); - let connection = client.with_publisher(origin).with_subscriber(sources).connect(url); - let monitor = connection.monitor(); - (connection, health::Link { endpoint, monitor }) - }) - .unzip() -} - /// What the program clock hands a rendition's encoder. enum Video { /// A copy of the program on its way to the encoder, to encode at this @@ -3197,16 +2846,50 @@ mod tests { /// Bounds each step, so a stall fails rather than hangs. const TIMEOUT: Duration = Duration::from_secs(30); - /// How the tests start a studio, live on `relays`. - fn launch(gpu: Gpu, relays: Vec, recordings: &Path) -> Launch { - Launch { + /// Start a studio recording into `recordings`, and go live on `relays` + /// as `studio` unless there are none. + async fn start( + gpu: Gpu, + relays: Vec, + recordings: &Path, + autosave: Autosave, + loaded: autosave::Loaded, + ) -> anyhow::Result> { + let launch = Launch { gpu, - relays, - broadcast: "studio".into(), - on_demand: false, recordings: recordings.to_path_buf(), room: None, + }; + let engine = Engine::start(launch, autosave, loaded).await?; + if !relays.is_empty() { + let destination = Destination { + relays, + broadcast: "studio".into(), + on_demand: false, + }; + engine.go_live(destination).await?; } + Ok(engine) + } + + /// A relay of its own, running, with a client that trusts it, what it + /// routes, and the config that makes another client for it. + async fn test_relay() -> (Relay, moq_net::origin::Consumer, moq_tokio::connect::Config) { + let _ = moq_tokio::crypto::install_default(); + let fixture = moq_relay::test_relay().await.expect("test relay"); + let ready = fixture.relay.ready(); + let routes = fixture.relay.cluster().origin.consume(); + tokio::spawn(fixture.relay.run()); + ready.wait().await.expect("relay ready"); + let mut client = moq_tokio::connect::Config::default(); + client.tls.fingerprint = vec![fixture.fingerprint.clone()]; + let config = client; + let client = config.clone().init(Default::default()).expect("client"); + let relay = Relay { + client, + url: fixture.url, + }; + (relay, routes, config) } /// A small canvas filled red, at two sizes. @@ -3314,11 +2997,12 @@ mod tests { let mut two = loaded.collection.scenes[0].clone(); two.name = "Two".into(); loaded.collection.scenes.push(two); - let engine = Engine::start(launch(gpu, Vec::new(), dir.path()), autosave, loaded) + let (relay, _routes, _) = test_relay().await; + let engine = start(gpu, vec![relay], dir.path(), autosave, loaded) .await - .expect("the studio starts"); + .expect("the studio goes live"); - let broadcast = engine.program.publication.broadcast().consume(); + let broadcast = engine.on_air_program.borrow().clone().expect("on air"); let mut catalogs = moq_mux::catalog::Consumer::<()>::new(&broadcast, Default::default()) .await .expect("the program's catalog"); @@ -3397,10 +3081,10 @@ mod tests { let dir = tempfile::tempdir().unwrap(); let gpu = Gpu::new(wgpu::Backends::all()).await.expect("a GPU"); let (autosave, _) = Autosave::open(dir.path().join("show.toml")).unwrap(); - let engine = Engine::start(launch(gpu, Vec::new(), dir.path()), autosave, red_canvas()) + let engine = start(gpu, Vec::new(), dir.path(), autosave, red_canvas()) .await .expect("the studio starts"); - assert!(engine.output.is_none()); + assert_eq!(engine.on_air(), OnAir::Off); assert_eq!(recorded(&engine), 0); assert_eq!( engine.stats.sessions.open(), @@ -3522,7 +3206,7 @@ mod tests { loaded.collection.video.insert("sting".into(), video); let gpu = Gpu::new(wgpu::Backends::all()).await.expect("a GPU"); let (autosave, _) = Autosave::open(dir.path().join("show.toml")).unwrap(); - let engine = Engine::start(launch(gpu, Vec::new(), dir.path()), autosave, loaded) + let engine = start(gpu, Vec::new(), dir.path(), autosave, loaded) .await .expect("the studio starts"); let status = |name: &str| engine.state.lock().unwrap().sources.get(name).map(source::Feed::status); @@ -3610,7 +3294,7 @@ mod tests { .extend([moq_scene::Scene::new("Guest"), brb, portrait]); let gpu = Gpu::new(wgpu::Backends::all()).await.expect("a GPU"); let (autosave, _) = Autosave::open(dir.path().join("show.toml")).unwrap(); - let engine = Engine::start(launch(gpu, Vec::new(), dir.path()), autosave, loaded) + let engine = start(gpu, Vec::new(), dir.path(), autosave, loaded) .await .expect("the studio starts"); { @@ -3976,7 +3660,7 @@ mod tests { ], ..moq_scene::Scene::new("tall") }); - let engine = Engine::start(launch(gpu, relays, dir.path()), autosave, loaded) + let engine = start(gpu, relays, dir.path(), autosave, loaded) .await .expect("the studio starts"); @@ -4311,7 +3995,7 @@ mod tests { sounds: ["bed".to_string()].into(), ..moq_scene::AudioScene::new("Portrait") }); - let engine = Engine::start(launch(gpu, relays, dir.path()), autosave, loaded) + let engine = start(gpu, relays, dir.path(), autosave, loaded) .await .expect("the studio starts"); @@ -4435,7 +4119,7 @@ mod tests { let camera = moq_net::Path::new("alice/camera.hang").unwrap(); room.observe(&camera, true, &Collection::new(), &History::new()); let origin = moq_tokio::origin::spawn(); - let program = engine.program.publication.broadcast().consume(); + let program = engine.on_air_program.subscribe(); let clock = engine.program.clock.clone(); let mut feeds = crate::feed::Feeds::new(room, origin.clone(), program, clock, Duration::ZERO).unwrap(); { @@ -4503,7 +4187,7 @@ mod tests { client, url: fixture.url.clone(), }]; - let engine = Engine::start(launch(gpu, relays, dir.path()), autosave, red_canvas()) + let engine = start(gpu, relays, dir.path(), autosave, red_canvas()) .await .expect("the studio starts"); assert!( @@ -4796,7 +4480,9 @@ mod tests { let origin = moq_tokio::origin::spawn(); let subscribe = moq_tokio::origin::spawn(); - let (_connections, links) = connect(relays, &origin, &subscribe); + let studio = moq_net::Path::new("studio").unwrap(); + let (_connections, _clients, links) = air::publish(relays.clone(), &origin, &studio); + let _watching = air::subscribe(&relays, &subscribe); let publication = origin.route("studio", Default::default()).unwrap(); let instance = publication.instance(); @@ -4882,7 +4568,96 @@ mod tests { .expect("both relays route the program, the failover the sources"); } - /// Closing the output as quitting does delivers the tail of every finished + /// Ending the stream ends the program's video and then its catalog cleanly + /// for a viewer at the relay, rather than cutting them, and the studio + /// runs on off air, where a replay of the program has nothing to copy and + /// says so. Going live again announces the program anew. + #[tokio::test(flavor = "multi_thread")] + #[ignore = "needs a Vulkan device and an H.264 encoder; run by just render-sw"] + async fn ending_the_stream_delivers_its_end_and_goes_live_again() { + let (relay, routes, config) = test_relay().await; + let dir = tempfile::tempdir().unwrap(); + let gpu = Gpu::new(wgpu::Backends::all()).await.expect("a GPU"); + let (autosave, _) = Autosave::open(dir.path().join("show.toml")).unwrap(); + let url = relay.url.clone(); + let engine = start(gpu, vec![relay], dir.path(), autosave, red_canvas()) + .await + .expect("the studio goes live"); + assert!(engine.on_air().live().is_some()); + assert!(engine.program_targets().is_ok(), "the program has a past on air"); + let (broadcast, catalogs, catalog) = routed(&routes, "studio").await; + let video = catalog.video.renditions.keys().next().expect("its video").clone(); + let viewer = served(&broadcast, &video).await; + + kio::clock::timeout(TIMEOUT, engine.end_stream()) + .await + .expect("the stream ends in time") + .expect("each relay takes the stream's end"); + assert_eq!(engine.on_air(), OnAir::Off); + ended(catalogs, viewer).await; + let refused = engine + .program_targets() + .err() + .expect("off air, the program has no past"); + assert!(format!("{refused:#}").contains("on air"), "{refused:#}"); + assert!(engine.end_stream().await.is_err(), "nothing is on air to end"); + + // Ending closed the last stream's clients, so this one dials anew. + let client = config.init(Default::default()).expect("client"); + let destination = Destination { + relays: vec![Relay { client, url }], + broadcast: "studio".into(), + on_demand: false, + }; + engine.go_live(destination).await.expect("the studio goes live again"); + let (_, _, again) = routed(&routes, "studio").await; + assert!(!again.video.renditions.is_empty(), "the program is announced anew"); + engine.stop(); + kio::clock::timeout(TIMEOUT, engine.close()) + .await + .expect("the studio closes"); + let failed = engine.stats.error(); + assert!(failed.is_none(), "{failed:?}"); + } + + /// Going live to a relay that never answers fails within the dial's + /// bound, naming the relay, and leaves the studio off air to try again. + #[tokio::test(flavor = "multi_thread")] + #[ignore = "needs a Vulkan device; run by just render-sw"] + async fn going_live_to_an_unreachable_relay_fails() { + let _ = moq_tokio::crypto::install_default(); + let dir = tempfile::tempdir().unwrap(); + let gpu = Gpu::new(wgpu::Backends::all()).await.expect("a GPU"); + let (autosave, _) = Autosave::open(dir.path().join("show.toml")).unwrap(); + let engine = start(gpu, Vec::new(), dir.path(), autosave, red_canvas()) + .await + .expect("the studio starts"); + assert_eq!(engine.on_air(), OnAir::Off); + // Nothing listens on the discard port. + let client = moq_tokio::connect::Config::default() + .init(Default::default()) + .expect("client"); + let destination = Destination { + relays: vec![Relay { + client, + url: "https://127.0.0.1:9/".parse().unwrap(), + }], + broadcast: "studio".into(), + on_demand: false, + }; + let refused = kio::clock::timeout(TIMEOUT, engine.go_live(destination)) + .await + .expect("going live gives up in time") + .expect_err("nothing answers"); + assert!(format!("{refused:#}").contains("127.0.0.1:9"), "{refused:#}"); + assert_eq!(engine.on_air(), OnAir::Off); + engine.stop(); + kio::clock::timeout(TIMEOUT, engine.close()) + .await + .expect("the studio closes"); + } + + /// Closing the sessions as ending the stream does delivers the tail of every finished /// track before the relay session goes: a subscriber at the relay reads /// each track's last group whole and then its end, and the broadcast is /// withdrawn. Each last group is still on its way as the close starts, so @@ -4906,20 +4681,12 @@ mod tests { let client = client.init(Default::default()).expect("client"); let origin = moq_tokio::origin::spawn(); - let (connections, _links) = connect( - vec![Relay { - client: client.clone(), - url: fixture.url.clone(), - }], - &origin, - &moq_tokio::origin::spawn(), - ); - let output = Output { - path: "studio".into(), - on_demand: false, - connections, - clients: vec![client], - }; + let studio = moq_net::Path::new("studio").unwrap(); + let relays = vec![Relay { + client: client.clone(), + url: fixture.url.clone(), + }]; + let (connections, clients, _links) = air::publish(relays, &origin, &studio); let publication = origin.route("studio", Default::default()).unwrap(); let info = || moq_net::track::Info::default().with_timescale(moq_net::Timescale::MILLI); let tracks = ["video", "audio"].map(|name| publication.broadcast().create_track(name, info()).unwrap()); @@ -4989,9 +4756,9 @@ mod tests { // The kept producer holds the finished track listed. drop(track.clone().finish().unwrap()); } - kio::clock::timeout(TIMEOUT, output.close()) + air::close(&connections, &clients) .await - .expect("the output closes"); + .expect("each relay takes the tail before its session closes"); for reader in readers { kio::clock::timeout(TIMEOUT, reader) .await @@ -5122,7 +4889,7 @@ mod tests { items: vec![moq_scene::Item::new("blue", fill)], ..moq_scene::Scene::new("tall") }); - let engine = Engine::start(launch(gpu, Vec::new(), dir.path()), autosave, loaded) + let engine = start(gpu, Vec::new(), dir.path(), autosave, loaded) .await .expect("the studio starts"); engine.set_camera(None, true).expect("the camera turns on"); diff --git a/rs/moq-studio/src/engine/air.rs b/rs/moq-studio/src/engine/air.rs new file mode 100644 index 00000000..e1550d29 --- /dev/null +++ b/rs/moq-studio/src/engine/air.rs @@ -0,0 +1,710 @@ +//! Going live and ending the stream. +//! +//! Off air the studio composes, previews, and records with no relay session +//! that publishes. Going live dials a session to each relay, announces the +//! program's broadcast on them, and opens its encoders; ending the stream +//! ends every track it lists, so each encoder publishes what it holds, and +//! closes the sessions once the relays have the broadcast's tail, as quitting +//! does. Each time on air is a broadcast of its own, with its own instance. +//! +//! Broadcast sources, guests, and viewers' reports arrive through sessions +//! of their own, which only subscribe, so they are seen off air too. + +use super::*; + +/// The longest going live waits for a relay to take the session. +const DIAL: Duration = Duration::from_secs(15); + +/// Where the program goes live. +#[derive(Clone)] +pub struct Destination { + /// The relays to publish to, the preferred first. Ending the stream + /// closes each one's client, so going live again takes new ones. + pub relays: Vec, + /// The broadcast path on them. + pub broadcast: String, + /// Whether the program video's canvas size is copied and encoded only + /// while someone watches it, rather than all the time. The half size + /// always is. + pub on_demand: bool, +} + +/// Whether the program is on air. +#[derive(Clone, Debug, PartialEq)] +pub enum OnAir { + Off, + /// Dialing the relays and opening the encoders. + Starting, + Live(Live), + /// Handing the relays the broadcast's tail. + Ending, +} + +impl OnAir { + /// The stream on air, if it is. + pub fn live(&self) -> Option<&Live> { + match self { + Self::Live(live) => Some(live), + _ => None, + } + } +} + +/// The stream on air. +#[derive(Clone, Debug, PartialEq)] +pub struct Live { + /// The broadcast path on the relays. + pub path: String, + /// Whether the canvas size encodes only while someone watches. + pub on_demand: bool, + /// When it went live. + pub since: Instant, + /// Each relay's scheme, host, and port, the preferred first. + pub relays: Vec, +} + +/// The engine's stream. +pub(super) enum Slot { + Off, + Starting, + Live(Box), + Ending, +} + +/// A stream on air: the sessions publishing it and what its broadcast lists +/// beside the video, which the program clock encodes ([`Lines`]). +pub(super) struct Air { + live: Live, + /// A session to each relay, which reconnects on its own. + connections: Vec, + /// The client that dialed each, whose endpoint sends the last close. + clients: Vec, + /// The program's broadcast, which closes once dropped. + publication: moq_net::origin::Route, + catalog: moq_scene::publish::Catalog, + /// Ends the program audio, which then finishes its track. + audio_stop: tokio::sync::oneshot::Sender<()>, + audio: tokio::task::JoinHandle<()>, + /// Its audio's claim on the connection's bandwidth, which it does not + /// follow: Opus at this rate is never what congests the uplink. Listed + /// under its track's name in [`Stats::grants`]. + _audio_grant: bandwidth::Reservation, + audio_track: String, + /// Copies the sources published independently into the broadcast. + forward: tokio::task::JoinHandle<()>, + /// Where the broadcasts are announced, which the sessions publish. + _origin: moq_net::origin::Producer, +} + +impl Drop for Air { + fn drop(&mut self) { + self.forward.abort(); + self.publication.broadcast().close(); + } +} + +/// What the program clock feeds while on air. +pub(super) struct Lines { + /// The program's. + pub main: Line, + /// What starts the line of each published scene. + pub extras: Extras, + /// The published scenes' lines. + pub lines: super::Lines, + /// Where and when the broadcast's viewers show the sources published + /// independently, while any is. + pub layout: moq_scene::layout::Publisher, +} + +impl Lines { + /// Stop handing every line frames, so each encode thread publishes what + /// it holds and finishes its track. + pub fn end(self) -> Ending { + let mut ended = vec![self.main.end(None)]; + ended.extend( + self.lines + .into_values() + .flatten() + .map(|(line, broadcast)| line.end(Some(broadcast))), + ); + Ending { + ended, + layout: Some(self.layout), + } + } +} + +/// What ending a stream leaves running, to wait on before the sessions close. +#[derive(Default)] +pub(super) struct Ending { + pub ended: Vec, + /// Finished once the video it lays out has ended. + pub layout: Option, +} + +/// What the program clock takes from going live and gives back on ending, +/// at its next tick. +#[derive(Default)] +pub(super) struct Handoff { + start: Option, + end: Option>, + /// Set once the program clock stops, after which nothing is taken. + closed: bool, +} + +impl Handoff { + /// What to start and whether to end, this tick. + pub fn take(&mut self) -> (Option, Option>) { + (self.start.take(), self.end.take()) + } + + /// Take nothing more, handing back what was waiting. + pub fn close(&mut self) -> (Option, Option>) { + self.closed = true; + self.take() + } +} + +/// A session to a relay that only subscribes. +pub(super) struct Watch { + pub(super) connection: moq_tokio::Connection, + pub(super) client: moq_tokio::Client, + pub(super) link: health::Link, +} + +/// Dial a session to each of `relays` that publishes what `origin` announces, +/// such as the broadcast at `path`, with each one's client and link. +pub(super) fn publish( + relays: Vec, + origin: &moq_net::origin::Producer, + path: &moq_net::Path, +) -> (Vec, Vec, Vec) { + let clients = relays.iter().map(|relay| relay.client.clone()).collect(); + let (connections, links) = relays + .into_iter() + .map(|Relay { client, url }| { + tracing::info!(url = %moq_tokio::RedactedUrl::new(&url), broadcast = %path, "going live"); + let endpoint = endpoint(&url); + let connection = client.with_publisher(origin).connect(url); + let monitor = connection.monitor(); + (connection, health::Link { endpoint, monitor }) + }) + .unzip(); + (connections, clients, links) +} + +/// Dial a session to each of `relays` that only subscribes, into +/// `subscribe`, the first relay's routes preferred. +pub(super) fn subscribe(relays: &[Relay], subscribe: &moq_net::origin::Producer) -> Vec { + relays + .iter() + .enumerate() + .map(|(rank, relay)| { + // The first relay's route to a broadcast wins while it has one, + // whether it carries the same instance as the failover's or another. + let preference = match rank { + 0 => moq_net::origin::Preference::default(), + _ => moq_net::origin::Preference::new(-1), + }; + let subscribe = subscribe.clone().with_preference(preference); + let connection = relay + .client + .clone() + .with_subscriber(subscribe) + .connect(relay.url.clone()); + let link = health::Link { + endpoint: endpoint(&relay.url), + monitor: connection.monitor(), + }; + Watch { + connection, + client: relay.client.clone(), + link, + } + }) + .collect() +} + +/// Close each of `connections` once its relay has what it was sent, and its +/// `clients`, bounded at [`CLOSE`]. +pub(super) async fn close(connections: &[moq_tokio::Connection], clients: &[moq_tokio::Client]) -> anyhow::Result<()> { + let mut closing = tokio::task::JoinSet::new(); + for (connection, client) in connections.iter().zip(clients) { + let (connection, client) = (connection.clone(), client.clone()); + closing.spawn(async move { + let drained = connection.close().await; + // So the relay hears the close rather than waiting out an idle + // timeout. + client.close().await; + drained + }); + } + let drained = kio::clock::timeout(CLOSE, closing.join_all()) + .await + .map_err(|_| anyhow::anyhow!("the relays did not take the stream's end within {CLOSE:?}"))?; + for drained in drained { + drained.context("a relay session closed without taking the stream's end")?; + } + Ok(()) +} + +impl Engine { + /// Whether the program is on air. + pub fn on_air(&self) -> OnAir { + self.on_air.borrow().clone() + } + + /// The GPU the program is drawn on, which going live's encoder check + /// times encoders on. + pub fn gpu(&self) -> &Gpu { + &self.gpu + } + + /// Move the stream to `slot`, and say so. + fn set_air(&self, slot: &mut Slot, to: Slot) { + let on_air = match &to { + Slot::Off => OnAir::Off, + Slot::Starting => OnAir::Starting, + Slot::Live(air) => OnAir::Live(air.live.clone()), + Slot::Ending => OnAir::Ending, + }; + *slot = to; + self.on_air.send_replace(on_air); + } + + /// Go live to `destination`: dial each relay, failing with why when none + /// takes the session, then open the program's encoders and announce its + /// broadcast, and each published scene's beneath it. The program audio + /// follows the audio scene on program, and guests' return feeds show the + /// program from now on. + /// + /// Call inside the tokio runtime that serves the relay connections. + pub async fn go_live(&self, destination: Destination) -> anyhow::Result<()> { + { + let mut slot = self.air.lock().unwrap(); + match &*slot { + Slot::Off => {} + Slot::Starting => anyhow::bail!("already going live"), + Slot::Live(_) => anyhow::bail!("already live"), + Slot::Ending => anyhow::bail!("the last stream is still ending"), + } + anyhow::ensure!(!self.stopped.load(Ordering::Relaxed), "the studio is quitting"); + self.set_air(&mut slot, Slot::Starting); + } + let lifted = self.lift(destination).await; + let mut slot = self.air.lock().unwrap(); + match lifted { + Ok(air) => { + self.set_air(&mut slot, Slot::Live(Box::new(air))); + Ok(()) + } + Err(err) => { + self.set_air(&mut slot, Slot::Off); + Err(err) + } + } + } + + /// Dial `destination`'s relays and start the stream on them. + async fn lift(&self, destination: Destination) -> anyhow::Result { + let Destination { + relays, + broadcast, + on_demand, + } = destination; + anyhow::ensure!(!relays.is_empty(), "no relay to go live on"); + let path = + moq_net::Path::new(broadcast.as_str()).with_context(|| format!("cannot publish at `{broadcast}`"))?; + let origin = moq_tokio::origin::spawn(); + let (connections, clients, links) = publish(relays, &origin, &path); + dial(&connections, &links).await?; + + // Each track reserves its ceiling on the first relay's estimate, which + // that connection then probes to fund: the bandwidth the stream is + // granted. An allocator spans one connection, so the failover's link is + // never probed. The catalog claims nothing itself, which would count + // each track twice. + let bandwidth = connections[0].allocator(); + let publication = origin + .route(&path, moq_net::origin::RouteOptions::hidden()) + .context("cannot create the broadcast")?; + let mut broadcast = publication.broadcast().clone(); + let clock = self.program.clock.clone(); + let config = moq_mux::catalog::Config::default() + .with_catalog(Default::default()) + .with_clock(clock.clone()); + let catalog = moq_scene::publish::Catalog::new(&mut broadcast, config)?; + // Held until the video and audio are listed, so the first catalog + // carries both and the solicitation. + let reserved = catalog.reserve(); + // Viewers report back beneath the broadcast. + health::solicit(&mut catalog.clone(), &path)?; + let renditions = Renditions { + gpu: self.gpu.clone(), + broadcast: broadcast.clone(), + timebase: catalog.timebase(), + record: false, + bandwidth: bandwidth.clone(), + on_demand, + live: true, + stats: self.stats.clone(), + video: self.stats.video.clone(), + grants: String::new(), + }; + // Opened before announcing, so a canvas this machine cannot encode + // fails going live rather than going live without a picture. The + // program clock probes again if the canvas changes meanwhile. + let canvas = self.state.lock().unwrap().compositor.canvas(); + let ladder = renditions.open(canvas).await; + let ladder = ladder.inspect_err(|err| self.stats.video.fail(format!("{err:#}")))?; + let main = Line::new(renditions, canvas, Some(ladder), true); + + let (input, options) = audio_options(); + let rate = input.sample_rate; + let mut audio = moq_audio::encode::Producer::new(&mut broadcast, catalog.clone(), input, &options)?; + let audio_grant = bandwidth.reserve(&audio.demand(), AUDIO_BITRATE); + let audio_track = audio.track_name().to_string(); + self.stats + .grants + .lock() + .unwrap() + .insert(audio_track.clone(), audio_grant.consume()); + drop(reserved); + + // One instance on every relay, so a viewer moving between them resumes + // mid-group rather than restarting. + let instance = publication.instance(); + if let Err(err) = publication.announce() { + // Taken back, as ending does, before saying why. + self.stats.grants.lock().unwrap().remove(&audio_track); + drop(main.end(None)); + return Err(err).context("cannot announce the broadcast"); + } + + let published = self.program.published.subscribe(); + let forward = { + let (sources, broadcast, catalog, bandwidth) = ( + self.program.sources.clone(), + broadcast.clone(), + catalog.clone(), + bandwidth.clone(), + ); + tokio::spawn(async move { + if let Err(err) = sources.forward(published, broadcast, catalog, bandwidth).await { + tracing::warn!(%err, "stopped publishing sources independently"); + } + }) + }; + let reports = self.subscribe.consume(); + let observer = hang::health::Observer::new(path.clone(), Some(instance)); + let publisher = health::Publisher { + main: health::Broadcast::follow(observer, catalog.clone(), &reports)?, + scenes: health::Scenes::new(reports), + clock: clock.clone(), + relays: links.clone(), + sources: self.program.sources.clone(), + }; + let extras = Extras { + origin: origin.clone(), + path: path.clone(), + clock, + epoch: self.program.epoch, + runtime: tokio::runtime::Handle::current(), + gpu: self.gpu.clone(), + bandwidth, + on_demand, + live: true, + stats: self.stats.clone(), + graded: Some(publisher.scenes.clone()), + }; + let layout = moq_scene::layout::Publisher::new(broadcast.clone(), catalog.clone()); + + // The audio scene on program, encoded on the runtime, never the + // program clock's thread. + let mut follow = self.program_audio.follow(); + let (audio_stop, stopped) = tokio::sync::oneshot::channel::<()>(); + let (stats, epoch) = (self.stats.clone(), self.program.epoch); + let audio = tokio::spawn(async move { + let encoded = tokio::select! { + encoded = mix::encode(&mut follow, &mut audio, epoch, rate) => encoded, + _ = stopped => Ok(()), + }; + match encoded { + // Fails only once the broadcast closed, which ended the track. + Ok(()) => drop(audio.finish()), + Err(err) => { + stats.fail_audio(format!("{err:#}")); + // Readers see the audio fail rather than go away unfinished. + audio.abort(moq_net::StreamError::Internal.into()); + } + } + }); + + let lines = Lines { + main, + extras, + lines: super::Lines::new(), + layout, + }; + { + let mut handoff = self.handoff.lock().unwrap(); + if handoff.closed { + drop(handoff); + // The program clock stopped meanwhile, so nothing will feed them. + let ending = lines.end(); + for ended in ending.ended { + ended.join(); + } + anyhow::bail!("the studio is quitting"); + } + handoff.start = Some(lines); + } + self.on_air_program + .send_replace(Some(publication.broadcast().consume())); + *self.sampler.lock().unwrap() = health::Sampler::new(Some(publisher)); + + Ok(Air { + live: Live { + path: path.to_string(), + on_demand, + since: kio::clock::now(), + relays: links.into_iter().map(|link| link.endpoint).collect(), + }, + connections, + clients, + publication, + catalog, + audio_stop, + audio, + _audio_grant: audio_grant, + audio_track, + forward, + _origin: origin, + }) + } + + /// End the stream: each encoder publishes what it holds and finishes its + /// track, the broadcast's catalog finishes, and each relay session closes + /// once the relay has received what it was sent, so a viewer or a + /// recording on the relay reaches the end rather than a cut. Bounded at + /// [`CLOSE`] for the sessions. Fails when nothing is on air. + pub async fn end_stream(&self) -> anyhow::Result<()> { + let air = { + let mut slot = self.air.lock().unwrap(); + let air = match std::mem::replace(&mut *slot, Slot::Off) { + Slot::Live(air) => air, + other => { + let why = match &other { + Slot::Off => "not live", + Slot::Starting => "still going live", + Slot::Live(_) => unreachable!("matched above"), + Slot::Ending => "already ending", + }; + *slot = other; + anyhow::bail!(why); + } + }; + self.set_air(&mut slot, Slot::Ending); + air + }; + let ending = { + let mut handoff = self.handoff.lock().unwrap(); + match handoff.closed { + // The program clock ended the encoders as it stopped. + true => None, + false => { + let (reply, ending) = tokio::sync::oneshot::channel(); + handoff.end = Some(reply); + Some(ending) + } + } + }; + let ending = match ending { + // The program clock stopping meanwhile drops the reply, having + // ended the encoders itself. + Some(ending) => ending.await.unwrap_or_default(), + None => Ending::default(), + }; + let landed = self.land(*air, ending).await; + let mut slot = self.air.lock().unwrap(); + self.set_air(&mut slot, Slot::Off); + landed + } + + /// Finish `air` once its encoders, `ending`, have, then close its + /// sessions. + async fn land(&self, mut air: Air, ending: Ending) -> anyhow::Result<()> { + let Ending { ended, layout } = ending; + let joined = tokio::task::spawn_blocking(move || { + for ended in ended { + ended.join(); + } + }); + if joined.await.is_err() { + tracing::error!("waiting on the encoders panicked"); + } + if let Some(mut layout) = layout { + finish_layout(&mut layout); + } + // Dropped, so the audio finishes its track. + let (stop, _) = tokio::sync::oneshot::channel(); + drop(std::mem::replace(&mut air.audio_stop, stop)); + if (&mut air.audio).await.is_err() { + tracing::error!("the program audio panicked"); + } + air.forward.abort(); + self.stats.grants.lock().unwrap().remove(&air.audio_track); + // Fails only once the catalog failed, which ended its tracks already. + let _ = air.catalog.clone().finish(); + self.on_air_program.send_replace(None); + *self.sampler.lock().unwrap() = health::Sampler::new(None); + + close(&air.connections, &air.clients).await + } + + /// What a replay of the program could copy: its video at each size, + /// largest first, with its audio, up to now. It has a past only on air, + /// as the relay's copy of it. + pub fn program_targets(&self) -> anyhow::Result> { + let slot = self.air.lock().unwrap(); + let Slot::Live(air) = &*slot else { + anyhow::bail!("the program has a past to replay only while on air"); + }; + let catalog = air.catalog.snapshot(); + let broadcast = air.publication.broadcast().consume(); + let end = self.program.clock.now(); + let target = |video, audio| moq_scene::replay::Target { + broadcast: broadcast.clone(), + video, + audio, + end, + }; + let audio = catalog.audio.renditions.into_iter().next(); + let mut video: Vec<_> = catalog.video.renditions.into_iter().collect(); + video.sort_by_key(|(_, config)| { + let pixels = u64::from(config.coded_width.unwrap_or(0)) * u64::from(config.coded_height.unwrap_or(0)); + std::cmp::Reverse(pixels) + }); + Ok(match video.is_empty() { + true => vec![target(None, audio)], + false => video + .into_iter() + .map(|video| target(Some(video), audio.clone())) + .collect(), + }) + } + + /// Subscribe to broadcast sources, guests, and viewers' reports through + /// `relays`, the preferred first, instead of those followed before. + pub fn watch(&self, relays: &[Relay]) { + let watching = subscribe(relays, &self.subscribe); + // Each dropped stops dialing, and its session goes. + drop(std::mem::replace(&mut *self.watching.lock().unwrap(), watching)); + } + + /// Each relay [watched](Self::watch), with its state and round trip. + pub fn watched(&self) -> Vec<(health::Relay, Option)> { + let watching = self.watching.lock().unwrap(); + watching + .iter() + .map(|watch| { + let rtt = watch.link.monitor.stats().and_then(|stats| stats.rtt); + (health::relay(&watch.link), rtt) + }) + .collect() + } + + /// Close each watching session, so its relay hears the close. + pub(super) async fn unwatch(&self) { + let watching = std::mem::take(&mut *self.watching.lock().unwrap()); + let mut closing = tokio::task::JoinSet::new(); + for Watch { connection, client, .. } in watching { + closing.spawn(async move { + // A session that only subscribes has nothing to drain. + let _ = connection.close().await; + client.close().await; + }); + } + closing.join_all().await; + } +} + +/// Wait until any of `connections` has a session, or fail with why the first +/// one could not, within [`DIAL`]. +async fn dial(connections: &[moq_tokio::Connection], links: &[health::Link]) -> anyhow::Result<()> { + let mut dialing: tokio::task::JoinSet<(usize, anyhow::Result<()>)> = tokio::task::JoinSet::new(); + for (index, connection) in connections.iter().enumerate() { + let connection = connection.clone(); + dialing.spawn(async move { + let established = connection.established().await.map(drop).map_err(anyhow::Error::from); + (index, established) + }); + } + let mut failures: Vec<(usize, anyhow::Error)> = Vec::new(); + let first = async { + while let Some(joined) = dialing.join_next().await { + match joined { + Ok((_, Ok(()))) => return true, + Ok((index, Err(err))) => failures.push((index, err)), + Err(err) => failures.push((usize::MAX, anyhow::anyhow!("the dial panicked: {err}"))), + } + } + false + }; + let connected = kio::clock::timeout(DIAL, first).await; + match connected { + Ok(true) => Ok(()), + Ok(false) => { + failures.sort_by_key(|(index, _)| *index); + let (index, err) = failures.into_iter().next().expect("every dial failed"); + let endpoint = links.get(index).map_or("the relay", |link| link.endpoint.as_str()); + Err(err.context(format!("cannot reach {endpoint}"))) + } + Err(_) => anyhow::bail!("no relay took the session within {} s", DIAL.as_secs()), + } +} + +/// The relay at `url` as the window names it: only the scheme, host, and +/// port, since a path can carry a credential, and the window may be on a +/// shared screen. A URL without a host, such as a unix socket's, keeps its +/// path, which is the address. +pub fn endpoint(url: &url::Url) -> String { + match url.host_str() { + Some(host) => match url.port() { + Some(port) => format!("{}://{host}:{port}", url.scheme()), + None => format!("{}://{host}", url.scheme()), + }, + None => format!("{}:{}", url.scheme(), url.path()), + } +} + +/// Publish the layer layout of what `state` drew on program at `at` on the +/// media clock, while any source is published independently. +pub(super) fn lay_out(publisher: &mut moq_scene::layout::Publisher, state: &State, at: Duration) { + // Past what a timestamp holds, the frame goes unstamped too. + let Ok(stamp) = moq_net::Timestamp::try_from(at) else { + return; + }; + let collection = &state.collection; + let published = match collection.published.is_empty() { + true => publisher.finish(), + false => { + // To the whole microsecond as the frame's stamp is, rather than + // rounded as the wire would, so a cut's layout starts on its frame. + let start = at.saturating_sub(state.compositor.program_since()).as_micros(); + let start = Duration::from_micros(start as u64); + let layout = moq_scene::layout::Layout::new(collection, state.compositor.program_scene(), start); + publisher.update(layout, stamp) + } + }; + if let Err(err) = published { + tracing::warn!(%err, "cannot publish the layer layout"); + } +} + +/// End the layer layout, once the video it lays out has ended. +pub(super) fn finish_layout(publisher: &mut moq_scene::layout::Publisher) { + if let Err(err) = publisher.finish() { + tracing::warn!(%err, "cannot finish the layer layout"); + } +} diff --git a/rs/moq-studio/src/feed.rs b/rs/moq-studio/src/feed.rs index 4b1ae897..ef526b79 100644 --- a/rs/moq-studio/src/feed.rs +++ b/rs/moq-studio/src/feed.rs @@ -2,11 +2,12 @@ //! //! Every guest the studio renews gets a broadcast at //! `.return//` in the room, which only their token may -//! read. Its video is the program's: the studio's session in the room serves the -//! program broadcast once at `.program`, and each feed's catalog lists its video -//! renditions by reference, so a guest costs no video encode. Its audio is its -//! own: a mix-minus of the audio scene on program without the guest's microphone, so -//! they follow the show without hearing themselves back. +//! read. Its video is the program's while on air: the studio's session in the +//! room serves the program broadcast once at `.program`, and each feed's catalog +//! lists its video renditions by reference, so a guest costs no video encode. +//! Off air it lists none. Its audio is its own, on air or not: a mix-minus of +//! the audio scene on program without the guest's microphone, so they follow +//! the show without hearing themselves back. //! //! The studio's session in the room publishes them, holding only what the room //! key signs. A guest costs one subtraction per audio block and an Opus encoder @@ -30,13 +31,16 @@ use crate::mix; /// not for broadcast. const BITRATE: moq_net::bandwidth::Rate = moq_net::bandwidth::Rate::from_kbps(64); +/// The program's broadcast while on air, and `None` off air. +pub type Program = tokio::sync::watch::Receiver>; + /// The return feeds of every renewed guest, and the program they show. pub struct Feeds { room: Arc, /// What the studio's session in the room publishes. origin: moq_net::origin::Producer, - /// The program broadcast, which each feed's video names. - program: moq_net::broadcast::Consumer, + /// The program broadcast while on air, which each feed's video names. + program: Program, /// The program catalog's clock, which each feed's catalog shares so its /// audio lines up with the program's video. clock: moq_mux::Clock, @@ -52,14 +56,14 @@ pub struct Feeds { } impl Feeds { - /// Serve `program` at [`PROGRAM`] in `room`, through `origin`, the studio's - /// session there, and publish a feed for each guest [`sync`](Self::sync) - /// finds renewed. `clock` and `epoch` are the program audio's, which the - /// feeds' audio is stamped against. + /// Serve the broadcast `program` holds while on air at [`PROGRAM`] in + /// `room`, through `origin`, the studio's session there, and publish a feed + /// for each guest [`sync`](Self::sync) finds renewed. `clock` and `epoch` + /// are the program audio's, which the feeds' audio is stamped against. pub fn new( room: Arc, origin: moq_net::origin::Producer, - program: moq_net::broadcast::Consumer, + program: Program, clock: moq_mux::Clock, epoch: Duration, ) -> anyhow::Result { @@ -69,10 +73,12 @@ impl Feeds { let served = program.clone(); let serving = tokio::spawn(async move { while let Some(request) = route.requested().await { - // The route claims everything beneath it too, which holds nothing. - match request.path().as_str() == PROGRAM { - true => request.serve(served.clone()), - false => request.reject(moq_net::Error::NotFound), + let on_air = served.borrow().clone(); + // The route claims everything beneath it too, which holds nothing, + // and off air the program is nowhere. + match on_air { + Some(program) if request.path().as_str() == PROGRAM => request.serve(program), + _ => request.reject(moq_net::Error::NotFound), } } }); @@ -203,8 +209,9 @@ struct Running { catalog: moq_mux::catalog::Producer, audio: moq_audio::encode::Producer, follow: mix::Follow, - /// The program broadcast, whose video renditions the catalog lists. - program: moq_net::broadcast::Consumer, + /// The program broadcast while on air, whose video renditions the catalog + /// lists. + program: Program, /// The program, relative to the feed. reference: moq_net::path::Relative, epoch: Duration, @@ -212,8 +219,9 @@ struct Running { } impl Running { - /// List the program's video and encode the picked audio until `stopped` - /// or the program ends, then finish the audio track and the catalog. + /// List the program's video while on air and encode the picked audio + /// until `stopped` or the studio closes, then finish the audio track and + /// the catalog. async fn run(mut self, stopped: tokio::sync::oneshot::Receiver<()>) -> anyhow::Result<()> { let Self { catalog, @@ -243,9 +251,47 @@ impl Running { } } +/// List in `catalog` the video renditions of the program on air, read from +/// the broadcast at `reference`, and none while it is off air, until the +/// studio closes. +async fn list( + program: &mut Program, + catalog: &mut moq_mux::catalog::Producer, + reference: &moq_net::path::Relative, +) -> anyhow::Result<()> { + loop { + let on_air = program.borrow_and_update().clone(); + // Whether the program changed before this one ended. + let changed = match &on_air { + Some(on_air) => tokio::select! { + changed = program.changed() => Some(changed.is_ok()), + listed = list_one(on_air, catalog, reference) => { + // The stream ending can cut its catalog, which says only that. + if let Err(err) = listed { + tracing::debug!(error = format!("{err:#}"), "the program's catalog ended"); + } + None + } + }, + None => None, + }; + let open = match changed { + Some(open) => open, + None => { + catalog.mutate(|catalog| catalog.video = Default::default())?; + program.changed().await.is_ok() + } + }; + // The studio closed. + if !open { + return Ok(()); + } + } +} + /// List the video renditions of each catalog `program` publishes in /// `catalog`, read from the broadcast at `reference`, until the program ends. -async fn list( +async fn list_one( program: &moq_net::broadcast::Consumer, catalog: &mut moq_mux::catalog::Producer, reference: &moq_net::path::Relative, @@ -295,21 +341,21 @@ mod tests { /// Return feeds on `origin` for the guests in `room`, of a program that /// lives as long as the returned broadcast and catalog. - fn feeds( - room: &Arc, - origin: &moq_net::origin::Producer, - ) -> (Feeds, (moq_net::broadcast::Producer, moq_mux::catalog::Producer)) { + fn feeds(room: &Arc, origin: &moq_net::origin::Producer) -> (Feeds, OnAir) { let (broadcast, catalog) = program(); - let feeds = Feeds::new( - room.clone(), - origin.clone(), - broadcast.consume(), - catalog.clock(), - Duration::ZERO, - ); - (feeds.unwrap(), (broadcast, catalog)) + let (on_air, program) = tokio::sync::watch::channel(Some(broadcast.consume())); + let feeds = Feeds::new(room.clone(), origin.clone(), program, catalog.clock(), Duration::ZERO); + (feeds.unwrap(), (on_air, broadcast, catalog)) } + /// The program on air, as the engine holds it, with its broadcast and + /// catalog. + type OnAir = ( + tokio::sync::watch::Sender>, + moq_net::broadcast::Producer, + moq_mux::catalog::Producer, + ); + /// Alice and bob in `room` with their cameras on, and a collection playing /// each camera, whose sources run on `bus`, which `mixed` follows. fn guests(room: &Room, bus: &Bus, mixed: Mixed) -> (Collection, Sources) { diff --git a/rs/moq-studio/src/guests.rs b/rs/moq-studio/src/guests.rs index eafbaad5..d781f84d 100644 --- a/rs/moq-studio/src/guests.rs +++ b/rs/moq-studio/src/guests.rs @@ -92,13 +92,12 @@ fn guest(path: &Path) -> Option<(Path, Kind)> { Some((identity, kind)) } -/// The guest flags. -#[derive(usage_rs::Args, Clone, Debug)] +/// The guest flags, which win over the show's own guest settings for a run. +#[derive(usage_rs::Args, Clone, Debug, Default)] #[usage(unknown_flags = "error", args_override_self = false)] pub struct Config { - /// The room guests join: a path under the `--connect` URL's, which the - /// studio's own connection must be allowed to subscribe to. Needs - /// `--room-key`. + /// The room guests join: a path under the relay's URL, which the studio's + /// own connection must be allowed to subscribe to. Needs `--room-key`. #[usage(long)] pub room: Option, @@ -116,28 +115,33 @@ pub struct Config { /// How long a join link, and each token the studio renews it with, works. A /// guest in the room is renewed every half of this, so a guest removed from - /// scenes is disconnected within it. At least a minute. - #[usage(long, default = "4h")] - pub guest_expiry: moq_tokio::cli::Duration, + /// scenes is disconnected within it. At least a minute. Defaults to 4h. + #[usage(long)] + pub guest_expiry: Option, } +/// How long a join link works unless the show or a flag says otherwise. +pub const DEFAULT_EXPIRY: Duration = Duration::from_secs(4 * 3600); + impl Config { - /// The room these flags describe on the relay at `connect`, or `None` without - /// `--room`, remembering who was removed from scenes beside the room key. + /// The room these settings describe on the relay at `connect`, or `None` + /// without a room, remembering who was removed from scenes beside the room + /// key. pub fn load(&self, connect: Option<&Url>) -> anyhow::Result> { let (room, key) = match (&self.room, &self.room_key, &self.join_page) { (None, None, None) => return Ok(None), (Some(room), Some(key), _) => (room, key), - _ => anyhow::bail!("guests need both --room and --room-key"), + _ => anyhow::bail!("guests need both a room and a room key"), }; let page = self .join_page .clone() .unwrap_or_else(|| Url::parse(JOIN_PAGE).expect("the default join page is a URL")); - let connect = connect.context("guests join through the relay; add --connect")?; + let connect = connect.context("guests join through the relay; set one in Settings, Stream")?; let removals = removals_path(key); let key = moq_auth::Key::from_file(key).with_context(|| format!("reading the room key {}", key.display()))?; - let room = Room::new(connect, room, key, page, self.guest_expiry.into())?; + let expiry = self.guest_expiry.map_or(DEFAULT_EXPIRY, Duration::from); + let room = Room::new(connect, room, key, page, expiry)?; Ok(Some(room.remember(removals)?)) } } @@ -919,7 +923,7 @@ pub(crate) mod tests { room: room.then(|| "guests".into()), room_key: key.then(|| path.clone()), join_page: page.then(|| Url::parse("https://studio.example/join/").unwrap()), - guest_expiry: EXPIRY.into(), + guest_expiry: Some(EXPIRY.into()), }; assert!(config(false, false, false).load(Some(&connect)).unwrap().is_none()); @@ -932,7 +936,7 @@ pub(crate) mod tests { assert!(err.to_string().contains("need both"), "{err}"); } let err = config(true, true, true).load(None).err().unwrap(); - assert!(err.to_string().contains("--connect"), "{err}"); + assert!(err.to_string().contains("relay"), "{err}"); let room = config(true, true, true).load(Some(&connect)).unwrap().unwrap(); assert_eq!(room.path().as_str(), "guests"); let link = room.invite("alice").unwrap().link; @@ -1437,7 +1441,7 @@ pub(crate) mod tests { room: Some("guests".into()), room_key: Some(path), join_page: None, - guest_expiry: EXPIRY.into(), + guest_expiry: Some(EXPIRY.into()), }; // Nothing the studio loads names the scene file, so another one sees the same state. let start = || config.load(Some(&connect)).unwrap().unwrap(); diff --git a/rs/moq-studio/src/health.rs b/rs/moq-studio/src/health.rs index 8227dd4f..46fee88b 100644 --- a/rs/moq-studio/src/health.rs +++ b/rs/moq-studio/src/health.rs @@ -634,7 +634,8 @@ impl Sampler { } } -fn relay(link: &Link) -> Relay { +/// How `link` is doing now. +pub(crate) fn relay(link: &Link) -> Relay { use moq_tokio::connection::Phase; let (state, version) = match link.monitor.state().phase { Phase::Connecting { .. } => (State::Connecting, None), diff --git a/rs/moq-studio/src/hotkeys/portal.rs b/rs/moq-studio/src/hotkeys/portal.rs index e744a236..e1bc5638 100644 --- a/rs/moq-studio/src/hotkeys/portal.rs +++ b/rs/moq-studio/src/hotkeys/portal.rs @@ -144,6 +144,8 @@ fn id(action: &Action, binding: &Binding) -> String { Action::SaveClip => "save-clip".into(), Action::Record => "record".into(), Action::Panic => "panic".into(), + Action::GoLive => "go-live".into(), + Action::EndStream => "end-stream".into(), } } diff --git a/rs/moq-studio/src/kit/icon.rs b/rs/moq-studio/src/kit/icon.rs index 7fe21654..89aba8fc 100644 --- a/rs/moq-studio/src/kit/icon.rs +++ b/rs/moq-studio/src/kit/icon.rs @@ -48,12 +48,20 @@ pub enum Icon { Build, Mix, Review, + Open, + Check, + Encoder, + Warning, + Landscape, + Portrait, + Uplink, + Camera, } impl Icon { /// Every icon, for the gallery. #[cfg(test)] - pub const ALL: [Self; 32] = [ + pub const ALL: [Self; 40] = [ Self::Undo, Self::Redo, Self::Settings, @@ -86,6 +94,14 @@ impl Icon { Self::Build, Self::Mix, Self::Review, + Self::Open, + Self::Check, + Self::Encoder, + Self::Warning, + Self::Landscape, + Self::Portrait, + Self::Uplink, + Self::Camera, ]; fn source(self) -> ImageSource<'static> { @@ -122,6 +138,14 @@ impl Icon { Self::Build => include_image!("../../assets/icons/layers.svg"), Self::Mix => include_image!("../../assets/icons/sliders-vertical.svg"), Self::Review => include_image!("../../assets/icons/film.svg"), + Self::Open => include_image!("../../assets/icons/folder-open.svg"), + Self::Check => include_image!("../../assets/icons/check.svg"), + Self::Encoder => include_image!("../../assets/icons/cpu.svg"), + Self::Warning => include_image!("../../assets/icons/triangle-alert.svg"), + Self::Landscape => include_image!("../../assets/icons/rectangle-horizontal.svg"), + Self::Portrait => include_image!("../../assets/icons/rectangle-vertical.svg"), + Self::Uplink => include_image!("../../assets/icons/upload.svg"), + Self::Camera => include_image!("../../assets/icons/video.svg"), } } diff --git a/rs/moq-studio/src/kit/widgets.rs b/rs/moq-studio/src/kit/widgets.rs index 5b4fde79..8ebd5194 100644 --- a/rs/moq-studio/src/kit/widgets.rs +++ b/rs/moq-studio/src/kit/widgets.rs @@ -300,10 +300,7 @@ impl<'a> Pill<'a> { #[cfg_attr( not(test), - expect( - dead_code, - reason = "the pages draw with it: the rest of quest/m0/ux, such as go-live.md" - ) + expect(dead_code, reason = "the pages draw with it: the rest of quest/m0/ux") )] pub fn value(mut self, value: &'a str) -> Self { self.value = Some(value); @@ -992,6 +989,9 @@ pub struct Pad<'a> { picture: Option, key: Option<&'a str>, tally: Tally, + /// The tag over the tally's own, such as FIRST for the scene a stream + /// opens on. + tag: Option<&'a str>, /// Why the scene cannot be taken, if it cannot. refused: Option<&'a str>, width: f32, @@ -1007,6 +1007,7 @@ impl<'a> Pad<'a> { picture: None, key: None, tally: Tally::Off, + tag: None, refused: None, width: 124.0, shape: 16.0 / 9.0, @@ -1031,6 +1032,12 @@ impl<'a> Pad<'a> { self } + /// Tagged `tag` in its tally's color, rather than the tally's own word. + pub fn tag(mut self, tag: Option<&'a str>) -> Self { + self.tag = tag; + self + } + /// Shown, but not takeable, for `why`. It still hears a click, such as /// for its menu, which its caller does not take it on. pub fn refused(mut self, why: Option<&'a str>) -> Self { @@ -1096,8 +1103,8 @@ impl Widget for Pad<'_> { } let tag_text = match self.tally { Tally::Off => None, - Tally::Air => Some("On air"), - Tally::Cue => Some("Next"), + Tally::Air => Some(self.tag.unwrap_or("On air")), + Tally::Cue => Some(self.tag.unwrap_or("Next")), }; if let Some(text) = tag_text { tag(painter, thumb.min + vec2(4.0, 4.0), text, self.tally, 11.0); @@ -1144,12 +1151,15 @@ fn shadow(painter: &egui::Painter, rect: Rect, corner: u8, color: Color32, blur: } /// The frame around the live picture: the accent while on air, amber and striped -/// while it shows a scene that is not, with a tag naming which. +/// while it shows a scene that is not, neutral off air, with a tag naming which. pub struct TallyFrame<'a> { tally: Tally, - tag: Option<&'a str>, + tag: Option<(&'a str, Tally)>, } +/// The neutral frame's outline, off air. +const NEUTRAL: Color32 = Color32::from_rgb(0x3a, 0x3a, 0x46); + impl<'a> TallyFrame<'a> { pub fn new(tally: Tally) -> Self { Self { tally, tag: None } @@ -1157,7 +1167,14 @@ impl<'a> TallyFrame<'a> { /// The tag in the picture's corner, such as ON AIR. pub fn tag(mut self, tag: &'a str) -> Self { - self.tag = Some(tag); + self.tag = Some((tag, self.tally)); + self + } + + /// The tag in `tally`'s color rather than the frame's, such as OFF AIR + /// in amber on the neutral frame. + pub fn tag_as(mut self, tag: &'a str, tally: Tally) -> Self { + self.tag = Some((tag, tally)); self } @@ -1192,9 +1209,11 @@ impl<'a> TallyFrame<'a> { painter.with_clip_rect(clip).set(band, Shape::Vec(stripes)); } painter.rect_stroke(outline, 12, Stroke::new(3.0, color), StrokeKind::Middle); + } else { + painter.rect_stroke(rect.expand(4.5), 12, Stroke::new(3.0, NEUTRAL), StrokeKind::Middle); } - if let Some(text) = self.tag { - tag(painter, rect.min + vec2(12.0, 12.0), text, self.tally, 15.0); + if let Some((text, tally)) = self.tag { + tag(painter, rect.min + vec2(12.0, 12.0), text, tally, 15.0); } if let (Some(fx), Some(mark)) = (effects, mark) { fx.program(&mark.around(rect)); diff --git a/rs/moq-studio/src/library.rs b/rs/moq-studio/src/library.rs new file mode 100644 index 00000000..2ebdabe8 --- /dev/null +++ b/rs/moq-studio/src/library.rs @@ -0,0 +1,689 @@ +//! The library: the shows this user has opened, newest first, each with the +//! last picture of its program, kept per user in the app's storage rather than +//! beside any show. The window opens on it when no show is named. + +use std::collections::HashMap; +use std::path::{Path, PathBuf}; +use std::time::Duration; + +use anyhow::Context; +use egui::{Align, Color32, Rect, Sense, Stroke, Ui, UiBuilder, Vec2, pos2, vec2}; + +use crate::engine::{Engine, Gpu}; +use crate::kit::{self, Icon}; +use crate::setup::Task; + +/// Where the list is kept in the app's storage. +const KEY: &str = "recent"; + +/// How many shows the list keeps. +const KEPT: usize = 30; + +/// How wide a saved picture is at most, enough for a card on a large screen. +const PICTURE: u32 = 640; + +/// The shows this user has opened, the latest first. +#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize)] +#[serde(default)] +pub struct Recent { + pub shows: Vec, +} + +/// A show in the list. +#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct Show { + /// Its scene file. + pub path: PathBuf, + /// When it was last opened, in seconds since the Unix epoch. + pub opened: u64, + /// Its last time on air, if it ever went live. + #[serde(default)] + pub live: Option, + /// Whether its canvas is taller than wide, as of its last picture. + #[serde(default)] + pub portrait: bool, +} + +/// A time on air. +#[derive(Clone, Copy, Debug, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct Aired { + /// When it went live, in seconds since the Unix epoch. + pub at: u64, + /// How long it stayed live, in seconds. + pub lasted: u64, +} + +/// Now, in seconds since the Unix epoch, on the ambient clock. +pub fn now() -> u64 { + kio::clock::wall() + .saturating_duration_since(kio::clock::Wall::UNIX_EPOCH) + .as_secs() +} + +impl Recent { + /// The list as the app's storage holds it, or none yet. + pub fn load(storage: Option<&dyn eframe::Storage>) -> Self { + storage + .and_then(|storage| eframe::get_value(storage, KEY)) + .unwrap_or_default() + } + + pub fn save(&self, storage: &mut dyn eframe::Storage) { + eframe::set_value(storage, KEY, self); + } + + /// The show at `path` was opened at `at`: it moves to the front. + pub fn opened(&mut self, path: &Path, at: u64) { + let path = absolute(path); + let index = self.shows.iter().position(|show| show.path == path); + let mut show = match index { + Some(index) => self.shows.remove(index), + None => Show { + path, + opened: at, + live: None, + portrait: false, + }, + }; + show.opened = at; + self.shows.insert(0, show); + self.shows.truncate(KEPT); + } + + /// The show at `path` was on air as `aired`. + pub fn aired(&mut self, path: &Path, aired: Aired) { + if let Some(show) = self.find(path) { + show.live = Some(aired); + } + } + + /// The show at `path` was last drawn `portrait` or not. + pub fn shaped(&mut self, path: &Path, portrait: bool) { + if let Some(show) = self.find(path) { + show.portrait = portrait; + } + } + + /// Take the show at `path` off the list, and its picture in `pictures` + /// with it. + pub fn forget(&mut self, path: &Path, pictures: Option<&Path>) { + self.shows.retain(|show| show.path != path); + if let Some(pictures) = pictures { + let _ = std::fs::remove_file(picture_path(pictures, path)); + } + } + + fn find(&mut self, path: &Path) -> Option<&mut Show> { + let path = absolute(path); + self.shows.iter_mut().find(|show| show.path == path) + } +} + +/// `path` from the root, so the list names a show once however it was +/// opened. +fn absolute(path: &Path) -> PathBuf { + std::path::absolute(path).unwrap_or_else(|_| path.to_path_buf()) +} + +/// Where the shows' pictures are kept: the app's storage. +pub fn pictures() -> Option { + eframe::storage_dir("moq-studio").map(|dir| dir.join("shows")) +} + +/// Where the picture of the show at `path` is kept in `pictures`, by a hash of +/// the show's path, so moving the show starts it without one. +pub fn picture_path(pictures: &Path, path: &Path) -> PathBuf { + let path = absolute(path); + // FNV-1a, which unlike std's hasher stays the same across releases. + let hash = path + .as_os_str() + .as_encoded_bytes() + .iter() + .fold(0xcbf2_9ce4_8422_2325_u64, |hash, byte| { + (hash ^ u64::from(*byte)).wrapping_mul(0x0100_0000_01b3) + }); + pictures.join(format!("{hash:016x}.png")) +} + +/// A picture in memory, as RGBA rows. +pub struct Picture { + pub width: u32, + pub height: u32, + pub rgba: Vec, +} + +impl Picture { + /// Whether it is taller than wide. + pub fn portrait(&self) -> bool { + self.height > self.width + } + + /// This picture, shrunk to `width` at most, by averaging each block of + /// pixels that becomes one. + fn shrink(self, width: u32) -> Self { + let step = self.width.div_ceil(width.max(1)).max(1); + if step == 1 { + return self; + } + let (out_width, out_height) = (self.width / step, self.height / step); + let mut rgba = Vec::with_capacity((out_width * out_height * 4) as usize); + for y in 0..out_height { + for x in 0..out_width { + let mut sum = [0u32; 4]; + for dy in 0..step { + for dx in 0..step { + let at = (((y * step + dy) * self.width + x * step + dx) * 4) as usize; + for (channel, total) in sum.iter_mut().enumerate() { + *total += u32::from(self.rgba[at + channel]); + } + } + } + rgba.extend(sum.map(|total| (total / (step * step)) as u8)); + } + } + Self { + width: out_width, + height: out_height, + rgba, + } + } +} + +/// Read the program's last frame back from the GPU, shrunk for a card. +pub fn capture(gpu: &Gpu, engine: &Engine) -> anyhow::Result { + let (buffer, width, height, row) = { + let state = engine.state.lock().unwrap(); + let texture = state.compositor.program(); + let (width, height) = (texture.width(), texture.height()); + let row = (width * 4).next_multiple_of(wgpu::COPY_BYTES_PER_ROW_ALIGNMENT); + let buffer = gpu.device.create_buffer(&wgpu::BufferDescriptor { + label: Some("show picture"), + size: u64::from(row) * u64::from(height), + usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::MAP_READ, + mapped_at_creation: false, + }); + let mut encoder = gpu.device.create_command_encoder(&Default::default()); + encoder.copy_texture_to_buffer( + texture.as_image_copy(), + wgpu::TexelCopyBufferInfo { + buffer: &buffer, + layout: wgpu::TexelCopyBufferLayout { + offset: 0, + bytes_per_row: Some(row), + rows_per_image: None, + }, + }, + texture.size(), + ); + gpu.queue.submit([encoder.finish()]); + (buffer, width, height, row) + }; + let (send, recv) = std::sync::mpsc::channel(); + buffer.map_async(wgpu::MapMode::Read, .., move |result| { + let _ = send.send(result); + }); + gpu.device + .poll(wgpu::PollType::wait_indefinitely()) + .context("cannot wait for the GPU")?; + recv.recv() + .context("the GPU dropped the read")? + .context("cannot read the program back")?; + let mapped = buffer + .slice(..) + .get_mapped_range() + .map_err(|err| anyhow::anyhow!("cannot read the program back: {err:?}"))?; + let mut rgba = Vec::with_capacity((width * height * 4) as usize); + for line in mapped.chunks(row as usize).take(height as usize) { + rgba.extend_from_slice(&line[..(width * 4) as usize]); + } + drop(mapped); + buffer.unmap(); + Ok(Picture { width, height, rgba }.shrink(PICTURE)) +} + +/// Keep `picture` as the show at `path`'s, in `pictures`. +pub fn save_picture(pictures: &Path, path: &Path, picture: &Picture) -> anyhow::Result<()> { + let file = picture_path(pictures, path); + let dir = pictures; + std::fs::create_dir_all(dir).with_context(|| format!("creating {}", dir.display()))?; + let mut out = tempfile::NamedTempFile::new_in(dir).with_context(|| format!("writing {}", file.display()))?; + { + let mut encoder = png::Encoder::new(std::io::BufWriter::new(&mut out), picture.width, picture.height); + encoder.set_color(png::ColorType::Rgba); + encoder.set_depth(png::BitDepth::Eight); + let mut writer = encoder.write_header().context("cannot encode the picture")?; + writer + .write_image_data(&picture.rgba) + .context("cannot encode the picture")?; + } + out.persist(&file) + .with_context(|| format!("writing {}", file.display()))?; + Ok(()) +} + +/// The picture kept for the show at `path` in `pictures`, if there is one. +fn load_picture(pictures: &Path, path: &Path) -> Option { + let file = std::fs::File::open(picture_path(pictures, path)).ok()?; + let mut decoder = png::Decoder::new(std::io::BufReader::new(file)); + decoder.set_transformations(png::Transformations::normalize_to_color8()); + let mut reader = decoder.read_info().ok()?; + let mut buffer = vec![0; reader.output_buffer_size()?]; + let info = reader.next_frame(&mut buffer).ok()?; + let size = [info.width as usize, info.height as usize]; + let pixels = &buffer[..info.buffer_size()]; + match info.color_type { + png::ColorType::Rgba => Some(egui::ColorImage::from_rgba_unmultiplied(size, pixels)), + png::ColorType::Rgb => Some(egui::ColorImage::from_rgb(size, pixels)), + _ => None, + } +} + +/// What the library asks the window for. +pub enum Pick { + /// Open the show at this path, or set it up if there is no file there. + Open(PathBuf), +} + +/// The library page. +pub struct Library { + /// Where the shows' pictures are kept, if anywhere. + dir: Option, + /// Each show's picture, loaded the first time it is drawn; `None` for one + /// without. + pictures: HashMap>, + /// Whether each show's file is still there, checked once. + found: HashMap, + /// The system's file dialog, while open. + dialog: Option>>, + /// Why the last show failed to open. + pub error: Option, + /// The show being opened, by name, while it opens. + pub opening: Option, +} + +impl Library { + /// The library, with the shows' pictures from `dir`. + pub fn new(dir: Option) -> Self { + Self { + dir, + pictures: HashMap::new(), + found: HashMap::new(), + dialog: None, + error: None, + opening: None, + } + } +} + +/// Room between cards. +const GAP: f32 = 22.0; +/// The height of a card's name and line under its picture. +const LABEL: f32 = 70.0; + +impl Library { + /// Draw the page; a show to open once one is picked. + pub fn ui(&mut self, ui: &mut Ui, recent: &mut Recent, runtime: &tokio::runtime::Handle) -> Option { + let mut pick = None; + if let Some(dialog) = &mut self.dialog { + ui.ctx().request_repaint_after(Duration::from_millis(100)); + if let Some(picked) = dialog.poll() { + pick = picked.clone().map(Pick::Open); + self.dialog = None; + } + } + let window = ui.max_rect(); + kit::wash(ui.painter(), window); + let width = (window.width() - 2.0 * 48.0).min(1220.0); + let column = Rect::from_center_size(pos2(window.center().x, window.center().y), vec2(width, window.height())) + .with_min_y(window.top() + 56.0); + let builder = UiBuilder::new() + .max_rect(column) + .layout(egui::Layout::top_down(Align::Min)); + ui.scope_builder(builder, |ui| { + egui::ScrollArea::vertical().show(ui, |ui| { + ui.set_width(width); + if self.heading(ui, runtime) { + self.dialog(runtime, false); + } + ui.add_space(20.0); + if let Some(error) = &self.error { + ui.colored_label(kit::ERR, error); + ui.add_space(12.0); + } + if let Some(name) = &self.opening { + ui.horizontal(|ui| { + ui.spinner(); + ui.label(format!("Opening {name}…")); + }); + ui.add_space(12.0); + } + let busy = self.opening.is_some() || self.dialog.is_some(); + ui.add_enabled_ui(!busy, |ui| { + if let Some(picked) = self.cards(ui, recent, width, runtime) { + pick = Some(picked); + } + }); + ui.add_space(40.0); + }); + }); + pick + } + + /// YOUR SHOWS, and Open a show file beside it; whether that was clicked. + fn heading(&mut self, ui: &mut Ui, _runtime: &tokio::runtime::Handle) -> bool { + ui.horizontal(|ui| { + ui.vertical(|ui| { + ui.label(kit::caps("Your shows", kit::display(44.0)).color(kit::TEXT)); + ui.label( + egui::RichText::new("Open one to pick up where it ended. Nothing goes live until you say so.") + .font(kit::ui(14.0)) + .color(kit::DIM), + ); + }); + ui.with_layout(egui::Layout::right_to_left(Align::Max), |ui| { + let open = kit::button(Icon::Open, "Open a show file").min_size(vec2(0.0, 38.0)); + ui.add_enabled(self.dialog.is_none(), open).clicked() + }) + .inner + }) + .inner + } + + /// Open the system's dialog: for a new show's file if `new`, or an + /// existing one's. + fn dialog(&mut self, runtime: &tokio::runtime::Handle, new: bool) { + let dialog = Task::spawn(runtime, move || async move { + let dialog = rfd::AsyncFileDialog::new().add_filter("Show", &["toml"]); + let picked = match new { + true => { + dialog + .set_title("Where to keep the new show") + .set_file_name("show.toml") + .save_file() + .await + } + false => dialog.set_title("Open a show").pick_file().await, + }; + picked.map(|file| file.path().to_path_buf()) + }); + match dialog { + Ok(dialog) => self.dialog = Some(dialog), + Err(err) => self.error = Some(format!("cannot open the file dialog: {err}")), + } + } + + /// The New show card and a card for each show, three to a row. + fn cards( + &mut self, + ui: &mut Ui, + recent: &mut Recent, + width: f32, + runtime: &tokio::runtime::Handle, + ) -> Option { + let columns = if width > 900.0 { 3 } else { 2 }; + let card = (width - GAP * (columns - 1) as f32) / columns as f32; + let size = vec2(card, card * 9.0 / 16.0 + LABEL); + let mut pick = None; + let mut forget = None; + let count = recent.shows.len() + 1; + for row in 0..count.div_ceil(columns) { + ui.horizontal(|ui| { + ui.spacing_mut().item_spacing.x = GAP; + for column in 0..columns { + let index = row * columns + column; + if index == 0 { + if self.new_card(ui, size).clicked() { + self.dialog(runtime, true); + } + continue; + } + let Some(show) = recent.shows.get(index - 1) else { break }; + let response = self.show_card(ui, show, size); + if response.clicked() && self.found(&show.path) { + pick = Some(Pick::Open(show.path.clone())); + } + response.context_menu(|ui| { + if ui.add(kit::button(Icon::Remove, "Forget this show")).clicked() { + forget = Some(show.path.clone()); + } + }); + } + }); + ui.add_space(GAP); + } + if let Some(path) = forget { + recent.forget(&path, self.dir.as_deref()); + self.pictures.remove(&path); + } + pick + } + + /// Whether the show at `path` is still there, checked the first time. + fn found(&mut self, path: &Path) -> bool { + *self + .found + .entry(path.to_path_buf()) + .or_insert_with(|| path.try_exists().unwrap_or(false)) + } + + /// The card that makes a new show. + fn new_card(&mut self, ui: &mut Ui, size: Vec2) -> egui::Response { + let (rect, response) = ui.allocate_exact_size(size, Sense::click()); + response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), "New show")); + let hovered = response.hovered(); + let painter = ui.painter(); + let stroke = Stroke::new(1.5, if hovered { kit::DIM } else { kit::LINE }); + crate::ui::dashed(painter, rect.shrink(1.0), stroke); + let center = rect.center() - vec2(0.0, 26.0); + painter.circle_filled(center, 30.0, if hovered { Color32::WHITE } else { kit::TEXT }); + Icon::Add.paint(ui, Rect::from_center_size(center, Vec2::splat(22.0)), 22.0, kit::BG); + let name = kit::caps_galley(painter, "New show", kit::display(24.0), kit::TEXT, None); + let at = pos2(rect.center().x - name.size().x / 2.0, center.y + 44.0); + painter.galley(at, name, kit::TEXT); + painter.text( + pos2(rect.center().x, at.y + 38.0), + egui::Align2::CENTER_TOP, + "Pick a shape, a camera, and a layout", + kit::ui(13.0), + kit::DIM, + ); + response + } + + /// A show's card: its picture, its name, and when it was last live. + fn show_card(&mut self, ui: &mut Ui, show: &Show, size: Vec2) -> egui::Response { + let found = self.found(&show.path); + let picture = self + .pictures + .entry(show.path.clone()) + .or_insert_with(|| { + let image = load_picture(self.dir.as_deref()?, &show.path)?; + let name = format!("show picture {}", show.path.display()); + Some(ui.ctx().load_texture(name, image, egui::TextureOptions::LINEAR)) + }) + .clone(); + let name = show + .path + .file_stem() + .unwrap_or(show.path.as_os_str()) + .to_string_lossy() + .into_owned(); + let (rect, response) = ui.allocate_exact_size(size, Sense::click()); + response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), &name)); + let response = response.on_hover_text(show.path.display().to_string()); + let painter = ui.painter(); + let hovered = response.hovered() && found; + painter.rect_filled(rect, 12, kit::P1); + let top = rect.with_max_y(rect.bottom() - LABEL); + let clip = painter.with_clip_rect(top.intersect(painter.clip_rect())); + clip.rect_filled( + top, + egui::CornerRadius { + nw: 12, + ne: 12, + sw: 0, + se: 0, + }, + Color32::BLACK, + ); + match &picture { + Some(texture) => { + let shape = texture.aspect_ratio(); + let fit = crate::ui::fit(top, shape); + let image = egui::Image::new(texture).corner_radius(0).tint(match found { + true => Color32::WHITE, + false => Color32::from_gray(90), + }); + image.paint_at(&ui.new_child(UiBuilder::new().max_rect(top)), fit); + } + None => { + let icon = if show.portrait { Icon::Portrait } else { Icon::Landscape }; + icon.paint( + ui, + Rect::from_center_size(top.center(), Vec2::splat(36.0)), + 36.0, + kit::FAINT, + ); + } + } + let painter = ui.painter(); + let label = rect.with_min_y(top.bottom()); + let ink = if found { kit::TEXT } else { kit::DIM }; + let title = kit::caps_galley(painter, &name, kit::display_bold(19.0), ink, Some(label.width() - 60.0)); + painter.galley(pos2(label.left() + 14.0, label.top() + 14.0), title, ink); + let line = match found { + true => said(show, crate::library::now()), + false => "Not where it was; right-click to forget it".to_string(), + }; + painter.text( + pos2(label.left() + 14.0, label.top() + 44.0), + egui::Align2::LEFT_TOP, + line, + kit::ui(12.5), + kit::DIM, + ); + let icon = if show.portrait { Icon::Portrait } else { Icon::Landscape }; + let at = Rect::from_center_size(pos2(label.right() - 26.0, label.center().y), Vec2::splat(18.0)); + icon.paint(ui, at, 18.0, kit::DIM); + let stroke = match hovered { + true => Stroke::new(1.5, kit::DIM), + false => Stroke::new(1.0, kit::LINE), + }; + ui.painter().rect_stroke(rect, 12, stroke, egui::StrokeKind::Inside); + response + } +} + +/// What a show's card says of it: when it was last live and for how long, or +/// when it was opened if it never went live. +pub fn said(show: &Show, now: u64) -> String { + match show.live { + Some(aired) => format!( + "Live {}, for {}", + ago(now.saturating_sub(aired.at)), + lasted(aired.lasted) + ), + None => format!("Opened {}, never live", ago(now.saturating_sub(show.opened))), + } +} + +/// `seconds` ago, as a person would say it. +fn ago(seconds: u64) -> String { + const MINUTE: u64 = 60; + const HOUR: u64 = 60 * MINUTE; + const DAY: u64 = 24 * HOUR; + const WEEK: u64 = 7 * DAY; + const MONTH: u64 = 30 * DAY; + const YEAR: u64 = 365 * DAY; + if seconds < MINUTE { + return "just now".into(); + } + // Each unit, below which the next takes over, and what one of it ago is. + let units = [ + (MINUTE, HOUR, "minute", None), + (HOUR, DAY, "hour", None), + (DAY, WEEK, "day", Some("yesterday")), + (WEEK, MONTH, "week", Some("last week")), + (MONTH, YEAR, "month", Some("last month")), + (YEAR, u64::MAX, "year", Some("last year")), + ]; + let (unit, _, name, last) = units + .into_iter() + .find(|(_, below, ..)| seconds < *below) + .unwrap_or(units[units.len() - 1]); + match (seconds / unit, last) { + (1, Some(last)) => last.into(), + (1, None) => format!("1 {name} ago"), + (count, _) => format!("{count} {name}s ago"), + } +} + +/// `seconds` on air, to the minute past the first. +fn lasted(seconds: u64) -> String { + let (hours, minutes) = (seconds / 3600, seconds / 60 % 60); + match (hours, minutes) { + (0, 0) => format!("{seconds} s"), + (0, minutes) => format!("{minutes} min"), + (hours, 0) => format!("{hours} h"), + (hours, minutes) => format!("{hours} h {minutes} min"), + } +} + +#[cfg(test)] +mod tests { + use super::*; + + /// A show opened again moves to the front rather than appearing twice, and + /// keeps when it was last live. + #[test] + fn reopening_moves_a_show_to_the_front() { + let mut recent = Recent::default(); + recent.opened(Path::new("/shows/a.toml"), 10); + recent.opened(Path::new("/shows/b.toml"), 20); + recent.aired(Path::new("/shows/a.toml"), Aired { at: 12, lasted: 60 }); + recent.opened(Path::new("/shows/a.toml"), 30); + let paths: Vec<_> = recent.shows.iter().map(|show| show.path.clone()).collect(); + assert_eq!(paths, [PathBuf::from("/shows/a.toml"), PathBuf::from("/shows/b.toml")]); + assert_eq!(recent.shows[0].opened, 30); + assert_eq!(recent.shows[0].live, Some(Aired { at: 12, lasted: 60 })); + } + + /// A card says when the show was last live and for how long, as a person + /// would. + #[test] + fn says_when_a_show_was_live() { + let day = 24 * 3600; + let show = |live| Show { + path: "/shows/a.toml".into(), + opened: 0, + live, + portrait: false, + }; + let now = 400 * day; + let aired = |ago: u64, lasted: u64| Some(Aired { at: now - ago, lasted }); + assert_eq!( + said(&show(aired(3 * day, 3 * 3600 + 120)), now), + "Live 3 days ago, for 3 h 2 min" + ); + assert_eq!(said(&show(aired(8 * day, 6000)), now), "Live last week, for 1 h 40 min"); + assert_eq!( + said(&show(aired(14 * day, 55 * 60)), now), + "Live 2 weeks ago, for 55 min" + ); + assert_eq!(said(&show(aired(40 * day, 7200)), now), "Live last month, for 2 h"); + assert_eq!(said(&show(None), now), "Opened last year, never live"); + } + + /// A picture shrinks by averaging, to the width asked for at most. + #[test] + fn shrinks_a_picture() { + let picture = Picture { + width: 4, + height: 2, + rgba: [[0, 0, 0, 255], [200, 100, 50, 255]].repeat(4).concat(), + }; + let small = picture.shrink(2); + assert_eq!((small.width, small.height), (2, 1)); + assert_eq!(&small.rgba[..4], &[100, 50, 25, 255]); + } +} diff --git a/rs/moq-studio/src/main.rs b/rs/moq-studio/src/main.rs index d79966e9..ac12d686 100644 --- a/rs/moq-studio/src/main.rs +++ b/rs/moq-studio/src/main.rs @@ -4,7 +4,7 @@ //! The scenes, sources, and compositor live in `moq-scene`; this binary is the //! window around them and the program clock that publishes the result. -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use std::process::ExitCode; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, OnceLock}; @@ -26,13 +26,16 @@ mod hotkeys; mod interact; mod kit; mod ladder; +mod library; mod mix; mod record; mod replay; mod setup; #[cfg(test)] mod shots; +mod show; mod snap; +mod stream; mod ui; mod uplink; mod vcam; @@ -43,8 +46,9 @@ mod watch; #[usage(name = "moq-studio")] #[usage(completion, settings, unknown_env(prefix = "MOQ_"))] pub struct Config { - /// The scene collection to open, saved as it changes. If it does not exist, - /// guided setup proposes one and creates it. + /// The show to open: its scene file, saved as it changes. If it does not + /// exist, guided setup proposes one and creates it. Without one, the + /// window opens on your recent shows. #[usage(value_hint = usage_rs::ValueHint::FilePath, extensions("toml"))] pub scenes: Option, @@ -56,18 +60,21 @@ pub struct Config { #[usage(long)] pub watch: Option, - /// The broadcast path the program is published at. - #[usage(long, default = "studio")] - pub broadcast: String, + /// The broadcast path the program goes live at, for this run, over the + /// show's own (Settings, Stream), which is `studio` until set. + #[usage(long)] + pub broadcast: Option, /// Copy and encode the program video at the canvas size only while someone - /// watches it, as the half size always is. This saves the work while - /// nobody does, but leaves a late viewer nothing from before they arrived. - /// Audio is always encoded, and a recording has an encoder of its own. + /// watches it, as the half size always is, for this run. This saves the + /// work while nobody does, but leaves a late viewer nothing from before + /// they arrived. Audio is always encoded, and a recording has an encoder + /// of its own. #[usage(long)] pub on_demand: bool, - /// The directory recordings are saved in. Defaults to the scene file's. + /// The directory recordings are saved in, for this run. Defaults to the + /// scene file's. #[usage(long, value_hint = usage_rs::ValueHint::DirPath)] pub recordings: Option, @@ -75,16 +82,16 @@ pub struct Config { #[usage(flatten)] pub guests: guests::Config, - /// The MoQ client configuration. Without `--connect`, nothing is published - /// and broadcast sources stay offline. + /// The MoQ client configuration. `--connect` names the relay to go live + /// on for this run, over the show's own, and `--connect-token` goes to it + /// alone. Nothing is published until you go live. #[usage(flatten)] pub client: moq_tokio::connect::Config, - /// A second relay to publish the same broadcast to, so a viewer linked to - /// both resumes from it when the `--connect` relay fails. Both must speak - /// the one `--connect-version`, which must carry broadcast instances. Its - /// credential rides its URL's `?jwt=`: `--connect-token` goes to the - /// `--connect` relay only. + /// A second relay to publish the same broadcast to, for this run, so a + /// viewer linked to both resumes from it when the first fails. Both must + /// speak the one `--connect-version`, which must carry broadcast instances. + /// Its credential is its own, from Settings or its URL's `?jwt=`. #[usage(long)] pub failover: Option, @@ -98,14 +105,10 @@ pub struct Config { } impl Config { - /// The scene file to open, refusing `--watch` beside the studio's own flags. - fn scenes(&self) -> anyhow::Result> { + /// Refuse `--watch` beside the studio's own flags. + fn check_watch(&self) -> anyhow::Result<()> { if self.watch.is_none() { - let scenes = self - .scenes - .as_deref() - .context("name a scene file to open, or --watch a broadcast")?; - return Ok(Some(scenes)); + return Ok(()); } anyhow::ensure!( self.scenes.is_none(), @@ -119,7 +122,7 @@ impl Config { self.guests.room.is_none(), "--watch publishes nothing, so it has no --room" ); - Ok(None) + Ok(()) } /// Refuse a config parsed from released spellings, naming what replaced each. @@ -130,48 +133,26 @@ impl Config { Ok(()) } - /// The relays to publish to, the `--connect` one first; none without it. - fn relays(&self) -> anyhow::Result> { - let Some(url) = self.client.url.clone() else { - anyhow::ensure!(self.failover.is_none(), "--failover needs --connect"); - return Ok(Vec::new()); - }; - if self.failover.is_some() { - self.check_failover()?; - } - let client = self.client.clone().init(self.quic.clone())?; - let mut relays = vec![engine::Relay { client, url }]; - if let Some(url) = self.failover.clone() { - let mut client = self.client.clone(); - // Its own credentials ride its URL; another operator's never reach it. - client.tokens.clear(); - let client = client - .init(self.quic.clone()) - .context("cannot set up the failover relay")?; - relays.push(engine::Relay { client, url }); + /// What the flags set for every show this run opens. + fn flags(&self) -> stream::Flags { + stream::Flags { + relay: self.client.url.clone(), + tokens: self.client.tokens.clone(), + failover: self.failover.clone(), + broadcast: self.broadcast.clone(), + on_demand: self.on_demand, + recordings: self.recordings.clone(), + guests: self.guests.clone(), } - Ok(relays) } - /// Refuse relays a viewer could not move between without a restart: a copy - /// resumes mid-group only under the same instance, which needs both links on - /// one protocol version that carries it. - fn check_failover(&self) -> anyhow::Result<()> { - let [version] = self.client.version.as_slice() else { - anyhow::bail!("--failover needs exactly one --connect-version, so both relays negotiate the same protocol"); - }; - anyhow::ensure!( - matches!(version, moq_net::Version::Lite(lite) if lite.has_instance()), - "--failover needs a --connect-version with broadcast instances (moq-lite-07-wip today), not {version}, \ - or a viewer moving between relays restarts the stream rather than resuming it" - ); - // Each relay's client binds its own socket, so a fixed port would be - // bound twice. - anyhow::ensure!( - self.client.bind.is_none_or(|bind| bind.port() == 0), - "--failover cannot share a fixed --connect-bind port between the two relays; leave the port 0" - ); - Ok(()) + /// Every other client flag, which each relay is dialed with: the relay and + /// its tokens come from the show, or the flags over it. + fn client(&self) -> moq_tokio::connect::Config { + let mut client = self.client.clone(); + client.url = None; + client.tokens.clear(); + client } } @@ -185,58 +166,36 @@ fn main() -> anyhow::Result { let config = Config::parse(); config.log.init()?; config.check_deprecated()?; - let Some(scenes) = config.scenes()? else { - let url = config.watch.clone().expect("checked by scenes"); + config.check_watch()?; + if let Some(url) = config.watch.clone() { watch::run(config.client.clone(), config.quic.clone(), url)?; return Ok(ExitCode::SUCCESS); - }; - let scenes = scenes.to_path_buf(); + } let runtime = tokio::runtime::Runtime::new()?; // The QUIC client binds its socket on the current runtime. let _runtime = runtime.enter(); - let relays = config.relays()?; let gpu = pollster::block_on(engine::Gpu::new(wgpu::Backends::all()))?; - let recordings = match &config.recordings { - Some(dir) => dir.clone(), - None => scenes - .parent() - .filter(|dir| !dir.as_os_str().is_empty()) - .unwrap_or(Path::new(".")) - .to_path_buf(), - }; - let room = config.guests.load(config.client.url.as_ref())?.map(Arc::new); - if let Some(room) = &room { - let renewal = guests::Renewal::connect(room.clone(), &config.client, config.quic.clone())?; - runtime.spawn(renewal.run()); - } - let launch = engine::Launch { + let opener = show::Opener { gpu: gpu.clone(), - relays, - broadcast: config.broadcast.clone(), - on_demand: config.on_demand, - recordings, - room, + runtime: runtime.handle().clone(), + flags: config.flags(), + client: config.client(), + quic: config.quic.clone(), + credentials: stream::Credentials::system(), }; - let exists = scenes - .try_exists() - .with_context(|| format!("reading {}", scenes.display()))?; - let app = match exists { - true => { - let (autosave, loaded) = autosave::Autosave::open(scenes.clone())?; - App::Starting(runtime.block_on(engine::Engine::start(launch, autosave, loaded))?) - } - // Nothing is saved until setup starts the studio, so quitting before then - // leaves no file and the next launch runs setup again. - false => App::Setup(Box::new(setup::Setup::new( - launch, - scenes.clone(), - runtime.handle().clone(), - )?)), + let app = match &config.scenes { + // Nothing is saved until setup starts the studio, so quitting before + // then leaves no file and the next launch runs setup again. + Some(scenes) => match runtime.block_on(opener.open(scenes.clone()))? { + show::Opened::Studio(engine, stream) => App::Starting(engine, stream), + show::Opened::Setup(setup, stream) => App::Setup(setup, stream), + }, + None => App::Library(Box::new(library::Library::new(library::pictures())), None), }; let started = Arc::new(OnceLock::new()); - let ran = run(app, gpu, runtime.handle().clone(), started.clone()); + let ran = run(app, opener, started.clone()); let Some(engine) = started.get() else { return ran.map(|()| ExitCode::SUCCESS); }; @@ -258,27 +217,40 @@ fn main() -> anyhow::Result { Ok(ExitCode::SUCCESS) } +/// A show being opened from the library. +type Opening = setup::Task>; + /// What the window shows. enum App { - /// First launch: guided setup, until it starts the studio. - Setup(Box), + /// No show open: the library, and the show it is opening. + Library(Box, Option), + /// A new show: guided setup, until it starts the studio. + Setup(Box, stream::Stream), /// An engine whose studio is built once the window can draw it. - Starting(Arc), + Starting(Arc, stream::Stream), Studio(Box), + /// Between two of the above, within the frame that moves from one to the + /// next. + Moving, } /// The window's contents, and what building the studio takes. struct Window { app: App, render: eframe::egui_wgpu::RenderState, - runtime: tokio::runtime::Handle, + opener: show::Opener, /// The engine once the studio is built, for the save on quit. started: Arc>>, + /// The shows this user has opened. + recent: library::Recent, + /// When the open show went live, in seconds since the Unix epoch, while + /// it is on air. + aired: Option, keyboard: hotkeys::Keyboard, /// The window's own effects, on the setup screen and in the studio. fx: fx::Fx, /// Whether the studio's title bar is the window's frame, rather than the - /// desktop's, which guided setup keeps. + /// desktop's, which the library and guided setup keep. framed: bool, /// Set once the window is asked to close, as [`Events::closed`] is. closed: Arc, @@ -291,6 +263,7 @@ impl eframe::App for Window { if ctx.input(|input| input.viewport().close_requested()) { self.closed.store(true, Ordering::Relaxed); } + self.follow_air(); if let App::Studio(studio) = &mut self.app { studio.logic(ctx, frame); } @@ -307,28 +280,111 @@ impl eframe::App for Window { if let App::Studio(studio) = &mut self.app { studio.save(storage); } + if let Some(engine) = self.started.get() { + let path = engine.autosave.path(); + // Its time on air so far, in case the window closes while live. + if let Some(at) = self.aired { + let lasted = library::now().saturating_sub(at); + self.recent.aired(path, library::Aired { at, lasted }); + } + // The show's picture is the program as it was when the window + // closed. + if self.closed.load(Ordering::Relaxed) { + let pictures = library::pictures().context("this system has no app storage"); + let picture = pictures.and_then(|pictures| Ok((pictures, library::capture(&self.opener.gpu, engine)?))); + let saved = picture.and_then(|(pictures, picture)| { + self.recent.shaped(path, picture.portrait()); + library::save_picture(&pictures, path, &picture) + }); + if let Err(err) = saved { + tracing::warn!(error = format!("{err:#}"), "cannot keep the show's picture"); + } + } + } + self.recent.save(storage); } } impl Window { - /// Draw setup or the studio, building the studio once its engine starts. + /// Draw the library, setup, or the studio, building the studio once its + /// engine starts. fn show(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame) { - let engine = match &mut self.app { - App::Studio(studio) => return studio.ui(ui, frame, &mut self.fx), - App::Setup(setup) => match setup.ui(ui, &mut self.fx) { - Some(engine) => engine, - None => return, + match std::mem::replace(&mut self.app, App::Moving) { + App::Studio(mut studio) => { + studio.ui(ui, frame, &mut self.fx); + self.app = App::Studio(studio); + } + App::Library(library, opening) => self.library(ui, library, opening), + App::Setup(mut setup, stream) => match setup.ui(ui, &mut self.fx) { + Some(engine) => { + self.app = App::Starting(engine, stream); + ui.ctx().request_repaint(); + } + None => self.app = App::Setup(setup, stream), }, - App::Starting(engine) => engine.clone(), - }; + App::Starting(engine, stream) => self.start(ui, frame, engine, stream), + App::Moving => unreachable!("the window moves between pages within a frame"), + } + } + + /// Draw the library, and open the show picked there, off this thread. + fn library(&mut self, ui: &mut egui::Ui, mut library: Box, mut opening: Option) { + if let Some(task) = &mut opening { + ui.ctx().request_repaint_after(std::time::Duration::from_millis(50)); + if task.poll().is_some() { + let Some(setup::Task::Done(opened)) = opening.take() else { + unreachable!("polled done") + }; + library.opening = None; + match opened { + Ok(show::Opened::Studio(engine, stream)) => { + self.app = App::Starting(engine, stream); + return ui.ctx().request_repaint(); + } + Ok(show::Opened::Setup(setup, stream)) => { + self.app = App::Setup(setup, stream); + return ui.ctx().request_repaint(); + } + Err(err) => library.error = Some(format!("{err:#}")), + } + } + } + let runtime = self.opener.runtime.clone(); + if let Some(library::Pick::Open(path)) = library.ui(ui, &mut self.recent, &runtime) { + let name = path.file_stem().unwrap_or(path.as_os_str()).to_string_lossy(); + library.opening = Some(name.into_owned()); + library.error = None; + let opener = self.opener.clone(); + match setup::Task::spawn(&runtime, move || async move { opener.open(path).await }) { + Ok(task) => opening = Some(task), + Err(err) => { + library.opening = None; + library.error = Some(format!("cannot open the show: {err}")); + } + } + } + self.app = App::Library(library, opening); + } + + /// Build the studio around `engine`, now that the window can draw it. + fn start( + &mut self, + ui: &mut egui::Ui, + frame: &mut eframe::Frame, + engine: Arc, + stream: stream::Stream, + ) { let _ = self.started.set(engine.clone()); - // After setup, the desktop's frame goes. macOS cannot draw under its - // title bar once the window is open, so it keeps it until a restart. + self.recent.opened(engine.autosave.path(), library::now()); + show::watch(&engine, &stream, &self.opener.runtime); + // Once a show is open, the desktop's frame goes. macOS cannot draw under + // its title bar once the window is open, so it keeps it until a restart. if !self.framed && !cfg!(target_os = "macos") { ui.ctx().send_viewport_cmd(egui::ViewportCommand::Decorations(false)); self.framed = true; } - let mut studio = ui::Studio::new(&self.render, engine, self.runtime.clone(), self.framed); + let runtime = self.opener.runtime.clone(); + let mut studio = ui::Studio::new(&self.render, engine, stream, runtime, self.framed); studio.load(hotkeys::Window { frame, ctx: ui.ctx(), @@ -337,6 +393,21 @@ impl Window { self.app = App::Studio(Box::new(studio)); ui.ctx().request_repaint(); } + + /// Note when the open show goes live, and how long it stayed once it ends. + fn follow_air(&mut self) { + let Some(engine) = self.started.get() else { return }; + let live = engine.on_air().live().map(|live| live.since.elapsed()); + match (live, self.aired) { + (Some(since), None) => self.aired = Some(library::now().saturating_sub(since.as_secs())), + (None, Some(at)) => { + let lasted = library::now().saturating_sub(at); + self.recent.aired(engine.autosave.path(), library::Aired { at, lasted }); + self.aired = None; + } + _ => {} + } + } } /// eframe's handler for the window's events, which hears keys before egui, @@ -420,16 +491,11 @@ fn icon() -> egui::IconData { } /// Show the window until it is closed. -fn run( - app: App, - gpu: engine::Gpu, - runtime: tokio::runtime::Handle, - started: Arc>>, -) -> anyhow::Result<()> { +fn run(app: App, opener: show::Opener, started: Arc>>) -> anyhow::Result<()> { // The studio's title bar is the window's: the desktop draws no frame, and - // macOS draws its buttons over the studio's bar. Guided setup keeps the - // desktop's until it starts the studio. - let framed = matches!(app, App::Starting(_)); + // macOS draws its buttons over the studio's bar. The library and guided + // setup keep the desktop's until a show opens. + let framed = matches!(app, App::Starting(..)); let mut viewport = egui::ViewportBuilder::default() .with_title("kixel.live Studio") // The Wayland app id and X11 class, which the desktop finds the @@ -447,6 +513,7 @@ fn run( false => viewport.with_decorations(false), }; } + let gpu = opener.gpu.clone(); let options = eframe::NativeOptions { viewport, wgpu_options: eframe::egui_wgpu::WgpuConfiguration { @@ -481,12 +548,15 @@ fn run( .clone() .context("the window is not drawn with wgpu")?; kit::install(&cc.egui_ctx); - let fx = fx::Fx::new(&render, cc.storage, &cc.egui_ctx, &runtime); + let fx = fx::Fx::new(&render, cc.storage, &cc.egui_ctx, &opener.runtime); + let recent = library::Recent::load(cc.storage); Ok(Box::new(Window { app, render, - runtime, + opener, started, + recent, + aired: None, keyboard: window_keyboard, fx, framed, @@ -510,73 +580,58 @@ fn run( #[cfg(test)] mod tests { - use std::time::Duration; - use super::*; + fn parse(args: &[&str]) -> Config { + let args: Vec<_> = args.iter().map(std::ffi::OsStr::new).collect(); + Config::parse_from(&args).unwrap() + } + + /// A scene file and a relay parse as flags over the show's own settings, + /// with the relay and its tokens taken out of the client every relay is + /// dialed with. #[test] fn parses_a_scene_file_and_a_relay() { - let config = Config::parse_from(&[ - std::ffi::OsStr::new("show.toml"), - std::ffi::OsStr::new("--connect"), - std::ffi::OsStr::new("http://localhost:4443"), - ]) - .expect("a scene file and a relay should parse"); + let config = parse(&[ + "show.toml", + "--connect", + "http://localhost:4443", + "--connect-token", + "secret", + ]); config.check_deprecated().unwrap(); - assert_eq!(config.scenes().unwrap(), Some(Path::new("show.toml"))); - assert_eq!(config.broadcast, "studio"); - assert!(!config.on_demand, "the program encodes whatever the demand by default"); - assert!(config.guests.room.is_none(), "guests are opt-in"); - assert_eq!( - Duration::from(config.guests.guest_expiry), - Duration::from_secs(4 * 3600) - ); - assert_eq!(config.client.url.unwrap().port(), Some(4443)); + config.check_watch().unwrap(); + assert_eq!(config.scenes.as_deref(), Some(std::path::Path::new("show.toml"))); + let flags = config.flags(); + assert_eq!(flags.broadcast, None, "the show's broadcast name stands"); + assert!(!flags.on_demand, "the program encodes whatever the demand by default"); + assert!(flags.guests.room.is_none(), "guests are opt-in"); + assert_eq!(flags.relay.unwrap().port(), Some(4443)); + assert_eq!(flags.tokens.len(), 1); + let client = config.client(); + assert!(client.url.is_none() && client.tokens.is_empty()); } - /// A failover relay is accepted only on one protocol version that carries - /// broadcast instances, so a viewer moving between the relays resumes rather - /// than restarts. + /// With no arguments the studio opens on the library. #[test] - fn failover_needs_one_version_with_instances() { - let check = |extra: &[&str]| { - let mut args = vec!["show.toml", "--connect", "https://a/", "--failover", "https://b/"]; - args.extend(extra); - let args: Vec<_> = args.into_iter().map(std::ffi::OsStr::new).collect(); - Config::parse_from(&args).unwrap().check_failover() - }; - let lite07 = ["--connect-version", "moq-lite-07-wip"]; - check(&lite07).expect("one version with instances"); - check(&[&lite07[..], &["--connect-bind", "127.0.0.1:0"]].concat()).expect("an ephemeral port"); - for refused in [ - &[][..], - &["--connect-version", "moq-lite-06"], - &["--connect-version", "moq-transport-22"], - &[&lite07[..], &["--connect-version", "moq-lite-06"]].concat(), - // Each relay binds its own socket. - &[&lite07[..], &["--connect-bind", "127.0.0.1:4444"]].concat(), - ] { - assert!(check(refused).is_err(), "{refused:?} was accepted"); - } + fn opens_with_no_arguments() { + let config = parse(&[]); + config.check_watch().unwrap(); + assert!(config.scenes.is_none() && config.watch.is_none()); } - /// `--watch` opens no scene file and names its own relay, and the studio - /// needs a scene file. + /// `--watch` opens no scene file and names its own relay. #[test] fn watch_takes_no_scene_file_or_relay() { - let parse = |args: &[&str]| { - let args: Vec<_> = args.iter().map(std::ffi::OsStr::new).collect(); - Config::parse_from(&args).unwrap() - }; - let watch = parse(&["--watch", "https://relay.example/anon/studio"]); - assert_eq!(watch.scenes().unwrap(), None); + parse(&["--watch", "https://relay.example/anon/studio"]) + .check_watch() + .unwrap(); for refused in [ &["show.toml", "--watch", "https://a/b"][..], &["--watch", "https://a/b", "--connect", "https://a/"], &["--watch", "https://a/b", "--room", "guests"], - &[], ] { - assert!(parse(refused).scenes().is_err(), "{refused:?} was accepted"); + assert!(parse(refused).check_watch().is_err(), "{refused:?} was accepted"); } } } diff --git a/rs/moq-studio/src/replay.rs b/rs/moq-studio/src/replay.rs index b92f4a57..5845a1d4 100644 --- a/rs/moq-studio/src/replay.rs +++ b/rs/moq-studio/src/replay.rs @@ -45,17 +45,12 @@ impl Engine { /// What a replay of `of` could copy, ending now, the most wanted first: /// the program at each of its sizes, largest first, or a source's one. /// - /// The program has a past only with a relay, from while it was encoded, a - /// local source, relay or not, only from while it was on program, shown or + /// The program has a past only on air, from while it was encoded, a local + /// source, on air or not, only from while it was on program, shown or /// heard, or recorded, and a broadcast source once it shows a picture. pub fn targets(&self, of: &Of) -> anyhow::Result> { let name = match of { - Of::Program => { - self.output - .as_ref() - .context("without --connect, the program holds no past to replay")?; - return Ok(self.program.program()); - } + Of::Program => return self.program_targets(), Of::Source(name) => name, }; let state = self.state.lock().unwrap(); diff --git a/rs/moq-studio/src/setup.rs b/rs/moq-studio/src/setup.rs index ff3cc03a..4ca548b3 100644 --- a/rs/moq-studio/src/setup.rs +++ b/rs/moq-studio/src/setup.rs @@ -17,7 +17,7 @@ use moq_scene::{Canvas, Collection, Draft, Edit, History, Item, Rect, Scene}; use crate::autosave::{self, Autosave}; use crate::devices::{self, Listing, Pick}; -use crate::engine::{self, Engine, Launch}; +use crate::engine::{self, Engine, Launch, Relay}; use crate::fx::{Fx, Mark}; use crate::health::rate; use crate::uplink; @@ -44,7 +44,7 @@ const fn canvas(width: u32, height: u32, framerate: u32) -> Canvas { /// Health panel's headroom grade healthy, so a proposal is not flagged the /// moment it goes live. The rest absorbs the estimate's error and whatever else /// shares the connection. -fn headroom() -> f64 { +pub(crate) fn headroom() -> f64 { 1.0 / hang::health::Thresholds::default().transport.headroom.degraded } @@ -79,12 +79,12 @@ pub struct Encoding { impl Encoding { /// What the program sends: this video plus the audio. - fn total(&self) -> Rate { + pub(crate) fn total(&self) -> Rate { Rate::from_bps(self.bitrate.as_bps() + engine::AUDIO_BITRATE.as_bps()) } /// Whether the encoder keeps up with `canvas` in real time, within [`PACE`]. - fn keeps_up(&self, canvas: Canvas) -> bool { + pub(crate) fn keeps_up(&self, canvas: Canvas) -> bool { self.frame <= budget(canvas) } @@ -136,6 +136,15 @@ async fn probe_encoders(gpu: engine::Gpu) -> Encoders { probed } +/// How `canvas` encodes on this machine, as going live checks it: the probe +/// setup runs for each canvas it could propose. +pub(crate) async fn probe(gpu: engine::Gpu, canvas: Canvas) -> Result { + let picture = Picture::new(&gpu); + probe_encoder(&gpu, &picture, canvas) + .await + .map_err(|err| format!("{err:#}")) +} + async fn probe_encoder(gpu: &engine::Gpu, picture: &Picture, canvas: Canvas) -> anyhow::Result { use moq_video::render::export::{Exporter, Route}; @@ -465,7 +474,7 @@ fn corner(canvas: &Canvas) -> Rect { } /// A result being worked out in the background. -enum Task { +pub(crate) enum Task { Running(mpsc::Receiver), Done(T), } @@ -476,7 +485,7 @@ impl Task { /// blocking pool, which dropping the runtime waits out, so a probe that never /// ends, such as one waiting on a camera permission prompt, cannot hold the /// studio open once its window closes. - fn spawn(runtime: &tokio::runtime::Handle, task: F) -> std::io::Result + pub(crate) fn spawn(runtime: &tokio::runtime::Handle, task: F) -> std::io::Result where F: FnOnce() -> Fut + Send + 'static, Fut: Future, @@ -493,7 +502,7 @@ impl Task { /// /// Panics if the task did, rather than waiting forever on a result that /// will never come. - fn poll(&mut self) -> Option<&T> { + pub(crate) fn poll(&mut self) -> Option<&T> { if let Self::Running(recv) = self { match recv.try_recv() { Ok(done) => *self = Self::Done(done), @@ -512,6 +521,8 @@ impl Task { pub struct Setup { runtime: tokio::runtime::Handle, launch: Launch, + /// The relay the uplink is measured to, and the broadcast measured as. + relay: Option<(Relay, String)>, /// The scene file, which does not exist until setup starts the studio. path: PathBuf, devices: Task, @@ -526,14 +537,21 @@ pub struct Setup { } impl Setup { - /// Start probing for `launch`, to create the scene file at `path`. - pub fn new(launch: Launch, path: PathBuf, runtime: tokio::runtime::Handle) -> std::io::Result { + /// Start probing for `launch`, to create the scene file at `path`, with + /// the uplink measured to `relay` as the broadcast it names. + pub fn new( + launch: Launch, + relay: Option<(Relay, String)>, + path: PathBuf, + runtime: tokio::runtime::Handle, + ) -> std::io::Result { let devices = Task::spawn(&runtime, devices::list)?; let gpu = launch.gpu.clone(); let encoders = Task::spawn(&runtime, move || probe_encoders(gpu))?; Ok(Self { runtime, launch, + relay, path, devices, encoders, @@ -598,15 +616,14 @@ impl Setup { .map(|(_, encoding)| encoding.total()) .max() .map(|top| top.scaled(1.0 / headroom())); - // The first relay's: the stream's tracks claim their bitrate on its + // The show's relay: the stream's tracks claim their bitrate on its // link alone, so it is the one probed toward the stream's rate. let connect = self - .launch - .relays - .first() - .map(|relay| (relay.client.clone(), relay.url.clone(), self.launch.broadcast.clone())); + .relay + .as_ref() + .map(|(relay, path)| (relay.client.clone(), relay.url.clone(), path.clone())); self.uplink = Some(match (connect, ceiling) { - (None, _) => Task::Done(Err("no relay is configured; start with --connect to measure it".into())), + (None, _) => Task::Done(Err("no relay is set yet, so it was not measured".into())), (Some(_), None) => Task::Done(Err("nothing encodes on this machine, so nothing would be sent".into())), (Some((client, url, path)), Some(ceiling)) => { let measured = Task::spawn(&self.runtime, move || async move { diff --git a/rs/moq-studio/src/shots.rs b/rs/moq-studio/src/shots.rs index 37cb446a..bfb49ad6 100644 --- a/rs/moq-studio/src/shots.rs +++ b/rs/moq-studio/src/shots.rs @@ -19,7 +19,7 @@ use moq_scene::source::Status; use crate::fx::Effects; use crate::ui::{Page, Setting, Tool}; -use crate::{App, Window, autosave, engine, fx, hotkeys, setup}; +use crate::{App, Window, autosave, engine, fx, hotkeys, library, setup, show, stream}; /// The window's size, the mock-ups'. const SIZE: egui::Vec2 = egui::vec2(1440.0, 900.0); @@ -34,12 +34,15 @@ const SETTLE: Duration = Duration::from_secs(20); enum Open { /// Guided setup, as the first launch shows it. Setup, + /// The library, as the app opens with no show, with a few recent shows. + Library, /// The studio on the show in `shots/`, in a window `size` large, - /// turned to `view`. + /// turned to `view`, with a relay of its own to go live on if `relay`. Studio { view: View, size: egui::Vec2, show: &'static str, + relay: bool, }, /// The kit's gallery, with a sheet open over it or not. Kit { sheet: bool }, @@ -57,6 +60,14 @@ enum View { /// The LIVE page after a mute, with the health dot's popover open and the /// pointer on undo, which names the mute. Hover, + /// The go-live sheet, once its checks finish. + Going, + /// On air, at the LIVE page. + OnAir, + /// On air, with the pointer on the clock. + EndStream, + /// On air, with the health dot's popover open. + OnAirHealth, } /// The studio on the shots' show, at the mock-ups' size, turned to `view`. @@ -65,6 +76,17 @@ fn studio(view: View) -> Open { view, size: SIZE, show: "show.toml", + relay: false, + } +} + +/// [`studio`], with a relay to go live on. +fn relayed(view: View) -> Open { + Open::Studio { + view, + size: SIZE, + show: "show.toml", + relay: true, } } @@ -105,16 +127,16 @@ views! { live_hover: Still, studio(View::Hover); /// A portrait show: the pages in a sidebar, and the scenes and the sound /// in columns beside the picture. - live_portrait: Still, Open::Studio { view: View::Page(Page::Live), size: SIZE, show: "portrait.toml" }; + live_portrait: Still, Open::Studio { view: View::Page(Page::Live), size: SIZE, show: "portrait.toml", relay: false }; /// A window snapped beside a game stacks the picture, the scenes, and the /// sound. - live_compact: Still, Open::Studio { view: View::Page(Page::Live), size: HALF, show: "show.toml" }; + live_compact: Still, Open::Studio { view: View::Page(Page::Live), size: HALF, show: "show.toml", relay: false }; build: Still, studio(View::Page(Page::Build)); /// MIX holds the mixer, and a small live picture in the sound's place. mix: Still, studio(View::Page(Page::Mix)); /// MIX in a stacked window, its live picture as tall as the sound's slot /// allows. - mix_compact: Still, Open::Studio { view: View::Page(Page::Mix), size: HALF, show: "show.toml" }; + mix_compact: Still, Open::Studio { view: View::Page(Page::Mix), size: HALF, show: "show.toml", relay: false }; review: Still, studio(View::Page(Page::Review)); graph: Still, studio(View::Setting(Setting::Graph)); history: Still, studio(View::Setting(Setting::History)); @@ -125,6 +147,22 @@ views! { /// Settings' Show tab, with the encoders' timings. output: Live, studio(View::Setting(Setting::Show)); hotkeys: Still, studio(View::Setting(Setting::Hotkeys)); + /// With no show open: recent shows, each with its picture, beside New + /// show and Open a show file. + library: Still, Open::Library; + /// GO LIVE's sheet: the relay with its switch and its state, and the + /// checks once they finish. + going: Live, relayed(View::Going); + /// On air: the accent frame, ON AIR, and the clock. + on_air: Live, relayed(View::OnAir); + /// On air, the pointer on the clock, which reads END STREAM. + end_stream: Live, relayed(View::EndStream); + /// On air, the health dot's popover: the worst problem, every + /// destination, the viewers, and the encoder. + on_air_health: Live, relayed(View::OnAirHealth); + /// Settings' Stream tab: the relay, its token, the failover, the + /// broadcast's name, and on demand. + settings_stream: Still, studio(View::Setting(Setting::Stream)); } /// Draw the view `name` opens into `$SHOTS_DIR/.png`, twice if it is @@ -191,27 +229,60 @@ fn lavapipe() -> (tempfile::TempDir, tokio::runtime::Runtime, engine::Gpu) { (show, runtime, gpu) } -/// How a view starts the studio: with no relay, recording beside the show. +/// How a view starts the studio: recording beside the show. fn launch(gpu: &engine::Gpu) -> engine::Launch { engine::Launch { gpu: gpu.clone(), - relays: Vec::new(), - broadcast: "studio".into(), - on_demand: false, recordings: ".".into(), room: None, } } +/// `show.toml`'s stream settings, on `relay` if given, with tokens in a store +/// of the test's own. +fn stream(relay: Option<&Relay>) -> stream::Stream { + let mut flags = stream::Flags::default(); + let mut client = moq_tokio::connect::Config::default(); + if let Some(relay) = relay { + flags.relay = Some(relay.url.clone()); + client.tls.fingerprint = vec![relay.fingerprint.clone()]; + } + let credentials = stream::Credentials::memory(); + stream::Stream::load(Path::new("show.toml"), flags, client, Default::default(), credentials).unwrap() +} + +/// A relay of the view's own, running on `runtime`. +struct Relay { + url: url::Url, + fingerprint: String, +} + +impl Relay { + fn start(runtime: &tokio::runtime::Runtime) -> Self { + runtime.block_on(async { + let _ = moq_tokio::crypto::install_default(); + let fixture = moq_relay::test_relay().await.expect("test relay"); + let ready = fixture.relay.ready(); + tokio::spawn(fixture.relay.run()); + ready.wait().await.expect("relay ready"); + Self { + url: fixture.url, + fingerprint: fixture.fingerprint, + } + }) + } +} + /// Start the studio by `launch` on `show.toml`, without the history an -/// earlier draw's edits left. -fn start(launch: engine::Launch, runtime: &tokio::runtime::Runtime) -> App { +/// earlier draw's edits left, streaming as `stream` sets. +fn start(launch: engine::Launch, stream: stream::Stream, runtime: &tokio::runtime::Runtime) -> App { let _ = std::fs::remove_file("show.history.toml"); let (autosave, loaded) = autosave::Autosave::open("show.toml".into()).unwrap(); App::Starting( runtime .block_on(engine::Engine::start(launch, autosave, loaded)) .unwrap(), + stream, ) } @@ -241,7 +312,8 @@ fn a_click_takes_and_the_panic_key_cuts() { room: Some(Arc::new(room)), ..launch(&gpu) }; - let (mut harness, started, closed) = window(start(launch, &runtime), &gpu, &runtime, SIZE); + let app = start(launch, stream(None), &runtime); + let (mut harness, started, closed) = window(app, &gpu, &runtime, SIZE, library::Recent::default()); harness.step(); let engine = started.get().expect("the studio started").clone(); runtime @@ -304,21 +376,30 @@ fn shoot(open: &Open, gpu: &engine::Gpu, runtime: &tokio::runtime::Runtime, show if let &Open::Kit { sheet } = open { return gallery(gpu, runtime, sheet); } + if let Open::Library = open { + let (app, recent) = shelf(); + let (mut harness, ..) = window(app, gpu, runtime, SIZE, recent); + // Enough for the pictures to load and the cards to settle. + harness.run_steps(4); + return harness.render().unwrap(); + } let app = match open { - Open::Setup => App::Setup(Box::new( - setup::Setup::new(launch(gpu), "show.toml".into(), runtime.handle().clone()).unwrap(), - )), - Open::Kit { .. } => unreachable!("drawn without an engine"), - Open::Studio { show, .. } => { + Open::Setup => { + let setup = setup::Setup::new(launch(gpu), None, "show.toml".into(), runtime.handle().clone()); + App::Setup(Box::new(setup.unwrap()), stream(None)) + } + Open::Kit { .. } | Open::Library => unreachable!("drawn without an engine"), + Open::Studio { show, relay, .. } => { std::fs::copy(shows.join(show), "show.toml").unwrap(); - start(launch(gpu), runtime) + let relay = relay.then(|| Relay::start(runtime)); + start(launch(gpu), stream(relay.as_ref()), runtime) } }; let size = match open { Open::Studio { size, .. } => *size, _ => SIZE, }; - let (mut harness, started, _) = window(app, gpu, runtime, size); + let (mut harness, started, _) = window(app, gpu, runtime, size, library::Recent::default()); let Open::Studio { view, .. } = open else { runtime @@ -330,19 +411,47 @@ fn shoot(open: &Open, gpu: &engine::Gpu, runtime: &tokio::runtime::Runtime, show let App::Studio(studio) = &mut harness.state_mut().app else { panic!("the studio starts on its first frame") }; + let controls = studio.controls(); match view { View::Page(page) => studio.turn(*page), View::Tool(tool) => studio.tool(*tool), View::Setting(setting) => studio.open(*setting), View::Health => studio.details(), - View::Hover => {} + View::Going => studio.going(), + View::Hover | View::OnAir | View::EndStream | View::OnAirHealth => {} } let engine = started.get().expect("the studio started").clone(); + if let View::OnAir | View::EndStream | View::OnAirHealth = view { + controls.go_live().expect("going live starts"); + runtime + .block_on(kio::clock::timeout(SETTLE, async { + while engine.on_air().live().is_none() { + kio::clock::sleep(Duration::from_millis(20)).await; + } + })) + .unwrap_or_else(|_| panic!("the studio goes live: {:?}", controls.refused.lock().unwrap())); + } runtime .block_on(kio::clock::timeout(SETTLE, settle(&mut harness, &engine))) .expect("the sources and pictures settle"); - if let View::Hover = view { - hover(&mut harness); + match view { + View::Hover => hover(&mut harness), + View::Going => runtime + .block_on(kio::clock::timeout(SETTLE, checks(&mut harness))) + .expect("the go-live checks finish"), + View::EndStream => { + harness.get_by_label("End stream").hover(); + harness.run_steps(2); + } + View::OnAirHealth => { + let pill = ["Healthy", "Starting", "Degraded", "Unhealthy"] + .into_iter() + .find_map(|name| harness.query_by_label(name)) + .expect("the health dot"); + pill.click(); + harness.run_steps(2); + } + _ => {} } let image = harness.render().unwrap(); drop(harness); @@ -357,7 +466,16 @@ fn window<'a>( gpu: &engine::Gpu, runtime: &'a tokio::runtime::Runtime, size: egui::Vec2, + recent: library::Recent, ) -> (Harness<'a, Window>, Arc>>, Arc) { + let opener = show::Opener { + gpu: gpu.clone(), + runtime: runtime.handle().clone(), + flags: Default::default(), + client: Default::default(), + quic: Default::default(), + credentials: stream::Credentials::memory(), + }; let render = render_state(gpu); let started = Arc::new(OnceLock::new()); let kept = started.clone(); @@ -374,8 +492,10 @@ fn window<'a>( Window { app, render: render.clone(), - runtime: runtime.handle().clone(), + opener, started: kept, + recent, + aired: None, keyboard: hotkeys::Keyboard::default(), fx, framed: true, @@ -422,18 +542,72 @@ fn hover(harness: &mut Harness<'_, Window>) { .expect("a sound to mute") .click(); harness.run_steps(2); - harness.get_by_label("Not live").click(); + harness.get_by_label("No relay").click(); harness.run_steps(2); harness.get_by_label_contains("Undo: Mute").hover(); // egui shows a tooltip once the pointer rests half a second. harness.run_steps(4); } +/// The library's shows: a few recent ones, beside the view's directory, most +/// with the person's picture as their last program. +fn shelf() -> (App, library::Recent) { + let pictures = std::path::absolute("pictures").unwrap(); + let person = image::open("person.jpg").unwrap().to_rgba8(); + let day = 24 * 3600; + let now = library::now(); + let shows = [ + ("Friday Night Ranked", Some((3 * day, 3 * 3600 + 120)), Some(false)), + ("Sunday Chill", Some((6 * day, 6000)), Some(false)), + ("Garage Sale Live", Some((14 * day, 55 * 60)), Some(true)), + ("Podcast with Sam", None, None), + ("Workbench Close-ups", Some((40 * day, 2 * 3600 + 900)), Some(false)), + ]; + let mut recent = library::Recent::default(); + // Oldest first, so the first is the latest opened. + for (index, (name, live, picture)) in shows.into_iter().enumerate().rev() { + let path = std::path::absolute(format!("{name}.toml")).unwrap(); + std::fs::write(&path, "").unwrap(); + recent.opened(&path, now - 21 * day + (5 - index as u64) * 3600); + if let Some((ago, lasted)) = live { + recent.aired(&path, library::Aired { at: now - ago, lasted }); + } + if let Some(portrait) = picture { + let (width, height) = if portrait { (360, 640) } else { (640, 360) }; + let picture = image::imageops::resize(&person, width, height, image::imageops::FilterType::Triangle); + let picture = library::Picture { + width, + height, + rgba: picture.into_raw(), + }; + recent.shaped(&path, portrait); + library::save_picture(&pictures, &path, &picture).unwrap(); + } + } + let app = App::Library(Box::new(library::Library::new(Some(pictures))), None); + (app, recent) +} + +/// Draw until the go-live sheet's checks finish. +async fn checks(harness: &mut Harness<'_, Window>) { + loop { + harness.step(); + let App::Studio(studio) = &harness.state().app else { + panic!("the studio stays open") + }; + if studio.checked() { + break; + } + kio::clock::sleep(Duration::from_millis(50)).await; + } + harness.run_steps(2); +} + /// Draw until setup has finished its checks and proposes a scene. async fn checked(harness: &mut Harness<'_, Window>) { loop { harness.step(); - let App::Setup(setup) = &harness.state().app else { + let App::Setup(setup, _) = &harness.state().app else { panic!("setup starts nothing on its own") }; if setup.proposing() { diff --git a/rs/moq-studio/src/show.rs b/rs/moq-studio/src/show.rs new file mode 100644 index 00000000..c304a4c1 --- /dev/null +++ b/rs/moq-studio/src/show.rs @@ -0,0 +1,108 @@ +//! Opening a show: its stream settings, its guests' room, and its engine, or +//! guided setup when its scene file does not exist yet. + +use std::path::PathBuf; +use std::sync::Arc; + +use anyhow::Context; + +use crate::autosave::Autosave; +use crate::engine::{self, Engine, Launch}; +use crate::stream::{self, Stream}; +use crate::{guests, setup}; + +/// What opening a show takes besides its path. +#[derive(Clone)] +pub struct Opener { + pub gpu: engine::Gpu, + pub runtime: tokio::runtime::Handle, + /// What the command line sets for every show this run opens. + pub flags: stream::Flags, + /// Every other client flag a relay is dialed with. + pub client: moq_tokio::connect::Config, + pub quic: moq_tokio::quic::Config, + pub credentials: stream::Credentials, +} + +/// A show, opened. +pub enum Opened { + /// Its engine, started. + Studio(Arc, Stream), + /// Guided setup, for a scene file that does not exist yet. + Setup(Box, Stream), +} + +impl Opener { + /// Open the show at `path`: start its engine, with its room's session for + /// guests when it has one, or guided setup when there is no scene file + /// there yet. Nothing goes live. + pub async fn open(&self, path: PathBuf) -> anyhow::Result { + let stream = Stream::load( + &path, + self.flags.clone(), + self.client.clone(), + self.quic.clone(), + self.credentials.clone(), + )?; + let room = stream.guests().load(stream.relay())?.map(Arc::new); + if let Some(room) = &room { + let renewal = guests::Renewal::connect(room.clone(), &stream.client(), stream.quic().clone())?; + self.runtime.spawn(renewal.run()); + } + let launch = Launch { + gpu: self.gpu.clone(), + recordings: stream.recordings(&path), + room, + }; + let exists = path + .try_exists() + .with_context(|| format!("reading {}", path.display()))?; + if exists { + let (autosave, loaded) = Autosave::open(path)?; + let engine = Engine::start(launch, autosave, loaded).await?; + return Ok(Opened::Studio(engine, stream)); + } + // The relay setup measures the uplink to, with its token, read off + // this task since the credential store blocks. + let measured = stream.clone(); + let relay = tokio::task::spawn_blocking(move || { + let only = stream::Switched { + relay: true, + failover: false, + }; + measured.relays(only) + }) + .await + .context("reading the relay's token panicked")?; + let uplink = match relay { + Ok(relays) => relays + .into_iter() + .next() + .map(|relay| (relay, stream.broadcast().to_string())), + Err(err) => { + tracing::warn!(error = format!("{err:#}"), "cannot measure the uplink"); + None + } + }; + let setup = setup::Setup::new(launch, uplink, path, self.runtime.clone())?; + Ok(Opened::Setup(Box::new(setup), stream)) + } +} + +/// Follow broadcast sources, guests, and viewers' reports through the show's +/// relays, read with their tokens on a thread of its own since the credential +/// store blocks. A relay that cannot be set up is logged; going live says why. +pub fn watch(engine: &Arc, stream: &Stream, runtime: &tokio::runtime::Handle) { + let (engine, stream, runtime) = (engine.clone(), stream.clone(), runtime.clone()); + let spawned = std::thread::Builder::new().name("watch".into()).spawn(move || { + // Each client binds its socket on the runtime. + let _runtime = runtime.enter(); + match stream.relays(stream::Switched::default()) { + Ok(relays) => engine.watch(&relays), + Err(err) => tracing::warn!(error = format!("{err:#}"), "cannot follow the relays"), + } + }); + if let Err(err) = spawned { + tracing::warn!(error = format!("{err:#}"), "cannot follow the relays"); + } +} diff --git a/rs/moq-studio/src/stream.rs b/rs/moq-studio/src/stream.rs new file mode 100644 index 00000000..df819c4d --- /dev/null +++ b/rs/moq-studio/src/stream.rs @@ -0,0 +1,600 @@ +//! Where a show streams: its relay, a failover relay, the broadcast's name, and +//! the options, kept per show in `.stream.toml` beside its scene file +//! rather than in it, since the scene file is meant to be shared and names no +//! relay. A relay's token goes in the operating system's credential store, +//! never in a file. Each command-line flag wins over its setting for the run it +//! is given to, and is never written back. + +use std::collections::HashMap; +use std::path::{Path, PathBuf}; +use std::sync::Arc; +use std::time::Duration; + +use anyhow::Context; +use url::Url; + +use crate::engine::{Destination, Relay}; +use crate::guests; + +/// The broadcast path a show without one goes live at. +pub const BROADCAST: &str = "studio"; + +/// What `.stream.toml` holds. +#[derive(Clone, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[serde(default, deny_unknown_fields)] +pub struct Saved { + /// The relay the program goes live on. + pub relay: Option, + /// A second relay to publish the same broadcast to, so a viewer linked to + /// both resumes from it when the first fails. + pub failover: Option, + /// The broadcast path on the relays, [`BROADCAST`] when unset. + pub broadcast: Option, + /// Whether the program video's canvas size encodes only while someone + /// watches it. + #[serde(skip_serializing_if = "std::ops::Not::not")] + pub on_demand: bool, + /// Where recordings are saved, the scene file's directory when unset. + pub recordings: Option, + /// The room guests join, a path beneath the relay's. + pub room: Option, + /// The key that signs guest tokens, a file `moq auth generate` writes. + pub room_key: Option, + /// The join page a guest opens. + pub join_page: Option, + /// How long a join link works. + #[serde(with = "humantime_serde")] + pub guest_expiry: Option, +} + +/// What the command line sets for one run, over the show's saved settings. +#[derive(Clone, Debug, Default)] +pub struct Flags { + pub relay: Option, + /// Credentials for the relay, over the one in the credential store. + pub tokens: Vec, + pub failover: Option, + pub broadcast: Option, + /// Set only to turn it on; off leaves the show's setting. + pub on_demand: bool, + pub recordings: Option, + pub guests: guests::Config, +} + +/// Which settings a flag sets for this run, so the window shows them as the +/// flags' and does not offer to change them. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub struct Overridden { + pub relay: bool, + pub token: bool, + pub failover: bool, + pub broadcast: bool, + pub on_demand: bool, +} + +/// Which relays a stream goes to, as the go-live sheet switches them. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct Switched { + pub relay: bool, + pub failover: bool, +} + +impl Default for Switched { + fn default() -> Self { + Self { + relay: true, + failover: true, + } + } +} + +/// A show's stream settings, as saved and as this run's flags override them. +#[derive(Clone)] +pub struct Stream { + /// `.stream.toml`. + path: PathBuf, + saved: Saved, + flags: Flags, + /// Every other client flag a relay is dialed with. + client: moq_tokio::connect::Config, + quic: moq_tokio::quic::Config, + credentials: Credentials, +} + +impl Stream { + /// The settings of the show at `scene`, as its stream file holds them, or + /// none yet, under `flags`. Each relay is dialed as `client` and `quic` + /// configure, with its token from `credentials`. + pub fn load( + scene: &Path, + flags: Flags, + client: moq_tokio::connect::Config, + quic: moq_tokio::quic::Config, + credentials: Credentials, + ) -> anyhow::Result { + let path = path(scene); + let saved = match std::fs::read_to_string(&path) { + Ok(text) => toml::from_str(&text).with_context(|| format!("reading {}", path.display()))?, + Err(err) if err.kind() == std::io::ErrorKind::NotFound => Saved::default(), + Err(err) => return Err(err).with_context(|| format!("reading {}", path.display())), + }; + Ok(Self { + path, + saved, + flags, + client, + quic, + credentials, + }) + } + + /// The stream file. + pub fn path(&self) -> &Path { + &self.path + } + + /// What the stream file holds. + pub fn saved(&self) -> &Saved { + &self.saved + } + + /// Which settings this run's flags set. + pub fn overridden(&self) -> Overridden { + let flags = &self.flags; + Overridden { + relay: flags.relay.is_some(), + token: !flags.tokens.is_empty(), + failover: flags.failover.is_some(), + broadcast: flags.broadcast.is_some(), + on_demand: flags.on_demand, + } + } + + /// The credential store the tokens are kept in. + pub fn credentials(&self) -> &Credentials { + &self.credentials + } + + /// Write `saved` to the stream file, all at once, so a crash leaves the + /// old file or the new one. A token in either relay's address moves to + /// the credential store first, so the file never holds one. + /// + /// Blocks on the credential store: call it off the window's thread, and + /// outside an async task. + pub fn save(&mut self, mut saved: Saved) -> anyhow::Result<()> { + for url in [&mut saved.relay, &mut saved.failover].into_iter().flatten() { + if let Some(token) = take_token(url) { + self.credentials.set(url, Some(&token))?; + } + } + let text = toml::to_string(&saved).context("cannot write the stream settings")?; + let dir = self + .path + .parent() + .filter(|dir| !dir.as_os_str().is_empty()) + .unwrap_or(Path::new(".")); + let mut file = + tempfile::NamedTempFile::new_in(dir).with_context(|| format!("writing {}", self.path.display()))?; + std::io::Write::write_all(&mut file, text.as_bytes()) + .with_context(|| format!("writing {}", self.path.display()))?; + file.persist(&self.path) + .with_context(|| format!("writing {}", self.path.display()))?; + self.saved = saved; + Ok(()) + } + + /// The relay the program goes live on. + pub fn relay(&self) -> Option<&Url> { + self.flags.relay.as_ref().or(self.saved.relay.as_ref()) + } + + /// The failover relay. + pub fn failover(&self) -> Option<&Url> { + self.flags.failover.as_ref().or(self.saved.failover.as_ref()) + } + + /// The broadcast path on the relays. + pub fn broadcast(&self) -> &str { + let set = self.flags.broadcast.as_deref().or(self.saved.broadcast.as_deref()); + set.unwrap_or(BROADCAST) + } + + /// Whether the canvas size encodes only while someone watches. + pub fn on_demand(&self) -> bool { + self.flags.on_demand || self.saved.on_demand + } + + /// Where recordings are saved for the show at `scene`. + pub fn recordings(&self, scene: &Path) -> PathBuf { + let set = self.flags.recordings.as_ref().or(self.saved.recordings.as_ref()); + match set { + Some(dir) => dir.clone(), + None => scene + .parent() + .filter(|dir| !dir.as_os_str().is_empty()) + .unwrap_or(Path::new(".")) + .to_path_buf(), + } + } + + /// The guests' room, as the flags and the show set it. + pub fn guests(&self) -> guests::Config { + let (flags, saved) = (&self.flags.guests, &self.saved); + guests::Config { + room: flags.room.clone().or(saved.room.clone()), + room_key: flags.room_key.clone().or(saved.room_key.clone()), + join_page: flags.join_page.clone().or(saved.join_page.clone()), + guest_expiry: flags.guest_expiry.or(saved.guest_expiry.map(Into::into)), + } + } + + /// The client flags with the relay's address, for the guests' room, which + /// takes none of its credentials. + pub fn client(&self) -> moq_tokio::connect::Config { + let mut client = self.client.clone(); + client.url = self.relay().cloned(); + client + } + + /// The QUIC tuning every relay is dialed with. + pub fn quic(&self) -> &moq_tokio::quic::Config { + &self.quic + } + + /// Each relay `switched` on, the preferred first, with its token, as a + /// client ready to dial it. Refuses a failover beside a relay a viewer + /// could not move between without a restart. + /// + /// Blocks on the credential store: call it off the window's thread, and + /// outside an async task. Call it inside the tokio runtime, where each + /// client binds its socket. + pub fn relays(&self, switched: Switched) -> anyhow::Result> { + self.dials(switched)? + .into_iter() + .map(|(url, tokens)| { + let mut client = self.client.clone(); + client.url = Some(url.clone()); + client.tokens = tokens; + let client = client + .init(self.quic.clone()) + .with_context(|| format!("cannot set up the relay {}", crate::engine::air::endpoint(&url)))?; + Ok(Relay { client, url }) + }) + .collect() + } + + /// Each relay `switched` on, the preferred first, with the tokens it is + /// dialed with: the flags' for the relay they name, or its own from the + /// credential store, so one relay's never reach another. + fn dials(&self, switched: Switched) -> anyhow::Result)>> { + let picked = [ + (switched.relay, self.relay(), !self.flags.tokens.is_empty()), + (switched.failover, self.failover(), false), + ]; + let picked: Vec<(&Url, bool)> = picked + .into_iter() + .filter_map(|(on, url, flagged)| Some((on.then_some(url?)?, flagged))) + .collect(); + if picked.len() > 1 { + self.check_failover()?; + } + picked + .into_iter() + .map(|(url, flagged)| { + let tokens = match flagged { + true => self.flags.tokens.clone(), + false => match self.credentials.get(url)? { + Some(token) => vec![token.parse().map_err(|err| anyhow::anyhow!("{err}"))?], + None => Vec::new(), + }, + }; + Ok((url.clone(), tokens)) + }) + .collect() + } + + /// Where going live with the relays `switched` on sends the program. + /// + /// Blocks as [`relays`](Self::relays) does. + pub fn destination(&self, switched: Switched) -> anyhow::Result { + let relays = self.relays(switched)?; + anyhow::ensure!( + !relays.is_empty(), + "no relay is switched on; set one in Settings, Stream" + ); + Ok(Destination { + relays, + broadcast: self.broadcast().to_string(), + on_demand: self.on_demand(), + }) + } + + /// Refuse relays a viewer could not move between without a restart: a + /// copy resumes mid-group only under the same instance, which needs both + /// links on one protocol version that carries it. + pub fn check_failover(&self) -> anyhow::Result<()> { + let [version] = self.client.version.as_slice() else { + anyhow::bail!( + "a failover relay needs exactly one --connect-version, so both relays negotiate the same protocol" + ); + }; + anyhow::ensure!( + matches!(version, moq_net::Version::Lite(lite) if lite.has_instance()), + "a failover relay needs a --connect-version with broadcast instances (moq-lite-07-wip today), not {version}, \ + or a viewer moving between relays restarts the stream rather than resuming it" + ); + // Each relay's client binds its own socket, so a fixed port would be + // bound twice. + anyhow::ensure!( + self.client.bind.is_none_or(|bind| bind.port() == 0), + "a failover relay cannot share a fixed --connect-bind port with the relay; leave the port 0" + ); + Ok(()) + } +} + +/// `show.stream.toml` for `show.toml`. +fn path(scene: &Path) -> PathBuf { + let mut name = scene.file_stem().unwrap_or(scene.as_os_str()).to_os_string(); + name.push(".stream.toml"); + scene.with_file_name(name) +} + +/// Take the token out of `url`'s `?jwt=`, if it has one, leaving the rest of +/// its query. +fn take_token(url: &mut Url) -> Option { + let mut token = None; + let kept: Vec<(String, String)> = url + .query_pairs() + .filter_map(|(key, value)| match key == "jwt" { + true => { + token = Some(value.into_owned()); + None + } + false => Some((key.into_owned(), value.into_owned())), + }) + .collect(); + token.as_ref()?; + match kept.is_empty() { + true => url.set_query(None), + false => { + url.query_pairs_mut().clear().extend_pairs(kept); + } + } + token +} + +/// What the credential store keeps tokens under. +const SERVICE: &str = "live.kixel.studio"; + +/// The operating system's credential store, where relay tokens are kept, one +/// per relay address. +#[derive(Clone)] +pub struct Credentials(Result, String>); + +impl Credentials { + /// This system's store: the Secret Service on Linux, the login keychain on + /// macOS, the Credential Manager on Windows. One that cannot open says why + /// whenever it is used. + pub fn system() -> Self { + Self(open().map_err(|err| format!("{err:#}"))) + } + + /// A store in memory, for tests. + #[cfg(test)] + pub fn memory() -> Self { + let store: Arc = keyring_core::mock::Store::new().expect("a mock store"); + Self(Ok(store)) + } + + /// The token kept for the relay at `url`, if any. + /// + /// Blocks on the store, which may ask the user to unlock it: call it off + /// the window's thread, and outside an async task. + pub fn get(&self, url: &Url) -> anyhow::Result> { + match self.entry(url)?.get_password() { + Ok(token) => Ok(Some(token)), + Err(keyring_core::Error::NoEntry) => Ok(None), + Err(err) => Err(err).context("cannot read the relay's token from the credential store"), + } + } + + /// Keep `token` for the relay at `url`, or forget its token with `None`. + /// + /// Blocks as [`get`](Self::get) does. + pub fn set(&self, url: &Url, token: Option<&str>) -> anyhow::Result<()> { + let entry = self.entry(url)?; + match token { + Some(token) => entry + .set_password(token) + .context("cannot save the relay's token in the credential store"), + None => match entry.delete_credential() { + Ok(()) | Err(keyring_core::Error::NoEntry) => Ok(()), + Err(err) => Err(err).context("cannot forget the relay's token in the credential store"), + }, + } + } + + /// The entry for the relay at `url`: its address without a query or a + /// fragment, which a token could ride. + fn entry(&self, url: &Url) -> anyhow::Result { + let store = self + .0 + .as_ref() + .map_err(|err| anyhow::anyhow!("no credential store: {err}"))?; + let mut user = url.clone(); + user.set_query(None); + user.set_fragment(None); + let modifiers: Option<&HashMap<&str, &str>> = None; + store + .build(SERVICE, user.as_str(), modifiers) + .context("cannot use the credential store") + } +} + +/// Open this system's credential store. +fn open() -> anyhow::Result> { + #[cfg(target_os = "linux")] + let store: Arc = zbus_secret_service_keyring_store::Store::new()?; + #[cfg(target_os = "macos")] + let store: Arc = apple_native_keyring_store::keychain::Store::new()?; + #[cfg(windows)] + let store: Arc = windows_native_keyring_store::Store::new()?; + #[cfg(not(any(target_os = "linux", target_os = "macos", windows)))] + anyhow::bail!("this system has no credential store the studio knows"); + #[cfg(any(target_os = "linux", target_os = "macos", windows))] + Ok(store) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn stream(dir: &Path, flags: Flags) -> Stream { + Stream::load( + &dir.join("show.toml"), + flags, + Default::default(), + Default::default(), + Credentials::memory(), + ) + .unwrap() + } + + /// The settings round-trip through the file beside the scene file, which + /// a token in a relay's address never reaches: the credential store takes + /// it, and the address keeps the rest of its query. + #[test] + fn saves_beside_the_scene_file_without_a_token() { + let dir = tempfile::tempdir().unwrap(); + let mut first = stream(dir.path(), Flags::default()); + assert_eq!(first.path(), dir.path().join("show.stream.toml")); + assert_eq!(first.broadcast(), BROADCAST); + let saved = Saved { + relay: Some("https://relay.example/anon?jwt=secret&keep=1".parse().unwrap()), + broadcast: Some("friday".into()), + on_demand: true, + guest_expiry: Some(Duration::from_secs(3600)), + ..Default::default() + }; + first.save(saved).unwrap(); + let text = std::fs::read_to_string(first.path()).unwrap(); + assert!(!text.contains("secret"), "the token reached the file: {text}"); + + let second = Stream::load( + &dir.path().join("show.toml"), + Flags::default(), + Default::default(), + Default::default(), + first.credentials().clone(), + ) + .unwrap(); + let relay = second.relay().unwrap().clone(); + assert_eq!(relay.as_str(), "https://relay.example/anon?keep=1"); + assert_eq!(second.broadcast(), "friday"); + assert!(second.on_demand()); + assert_eq!( + second.guests().guest_expiry.map(Duration::from), + Some(Duration::from_secs(3600)) + ); + assert_eq!(second.credentials().get(&relay).unwrap().as_deref(), Some("secret")); + } + + /// A flag wins over the saved setting for its run, and saving another + /// setting never writes the flag's value back. + #[test] + fn flags_win_and_are_never_saved() { + let dir = tempfile::tempdir().unwrap(); + let saved = Saved { + relay: Some("https://saved.example/".parse().unwrap()), + broadcast: Some("saved".into()), + ..Default::default() + }; + stream(dir.path(), Flags::default()).save(saved.clone()).unwrap(); + let flags = Flags { + relay: Some("https://flag.example/".parse().unwrap()), + on_demand: true, + ..Default::default() + }; + let mut flagged = stream(dir.path(), flags); + assert_eq!(flagged.relay().unwrap().as_str(), "https://flag.example/"); + assert_eq!(flagged.broadcast(), "saved"); + assert!(flagged.on_demand()); + let overridden = flagged.overridden(); + assert!(overridden.relay && overridden.on_demand && !overridden.broadcast); + + flagged + .save(Saved { + broadcast: Some("renamed".into()), + ..flagged.saved().clone() + }) + .unwrap(); + let reread = stream(dir.path(), Flags::default()); + assert_eq!(reread.relay().unwrap().as_str(), "https://saved.example/"); + assert_eq!(reread.broadcast(), "renamed"); + assert!(!reread.on_demand()); + } + + /// An unknown key is refused rather than dropped on the next save. + #[test] + fn refuses_an_unknown_setting() { + let dir = tempfile::tempdir().unwrap(); + std::fs::write(dir.path().join("show.stream.toml"), "relays = []\n").unwrap(); + let loaded = Stream::load( + &dir.path().join("show.toml"), + Flags::default(), + Default::default(), + Default::default(), + Credentials::memory(), + ); + assert!(loaded.is_err()); + } + + /// Each relay switched on is dialed with its own token: the flags' for the + /// relay they name, the store's for the failover, and a failover is + /// refused unless both relays resume the same broadcast. + #[test] + fn each_relay_gets_its_own_token() { + let dir = tempfile::tempdir().unwrap(); + let relay: Url = "https://a.example/".parse().unwrap(); + let failover: Url = "https://b.example/".parse().unwrap(); + let mut client = moq_tokio::connect::Config::default(); + let credentials = Credentials::memory(); + credentials.set(&failover, Some("b-token")).unwrap(); + let flags = Flags { + relay: Some(relay.clone()), + tokens: vec!["a-token".parse().unwrap()], + failover: Some(failover.clone()), + ..Default::default() + }; + let load = |client: moq_tokio::connect::Config| { + Stream::load( + &dir.path().join("show.toml"), + flags.clone(), + client, + Default::default(), + credentials.clone(), + ) + .unwrap() + }; + assert!( + load(client.clone()).dials(Switched::default()).is_err(), + "no single version" + ); + client.version = vec!["moq-lite-07-wip".parse().unwrap()]; + let stream = load(client); + let token = |token: &str| -> Vec { vec![token.parse().unwrap()] }; + let dials = stream.dials(Switched::default()).unwrap(); + assert_eq!(dials, [(relay, token("a-token")), (failover.clone(), token("b-token"))]); + let alone = Switched { + relay: false, + failover: true, + }; + assert_eq!(stream.dials(alone).unwrap(), [(failover, token("b-token"))]); + let none = Switched { + relay: false, + failover: false, + }; + assert!(stream.destination(none).is_err(), "nothing to send"); + } +} diff --git a/rs/moq-studio/src/ui.rs b/rs/moq-studio/src/ui.rs index 049c8f8f..d1f1ddaa 100644 --- a/rs/moq-studio/src/ui.rs +++ b/rs/moq-studio/src/ui.rs @@ -33,12 +33,15 @@ mod build; mod graph; mod layout; mod levels; +mod live; mod mixer; mod review; mod settings; mod shell; +pub(crate) use layout::fit; use levels::{Levels, meter}; +pub(crate) use shell::dashed; /// The smallest the window gets, at which every part still has room. pub const MIN_SIZE: egui::Vec2 = layout::MIN; @@ -91,14 +94,24 @@ pub(crate) enum Setting { /// Every source, scene, and audio scene, wired. Graph, History, + /// Where the show streams: its relays, their tokens, and the broadcast. + Stream, } impl Setting { - const ALL: [Self; 5] = [Self::Show, Self::Hotkeys, Self::Effects, Self::Graph, Self::History]; + const ALL: [Self; 6] = [ + Self::Show, + Self::Stream, + Self::Hotkeys, + Self::Effects, + Self::Graph, + Self::History, + ]; fn name(self) -> &'static str { match self { Self::Show => "Show", + Self::Stream => "Stream", Self::Hotkeys => "Hotkeys", Self::Effects => "Effects", Self::Graph => "Graph", @@ -116,10 +129,12 @@ pub struct Studio { } impl Studio { - /// The studio on `engine`, `framed` if its title bar is the window's frame. + /// The studio on `engine`, streaming as `stream` sets, `framed` if its + /// title bar is the window's frame. pub fn new( render: &eframe::egui_wgpu::RenderState, engine: Arc, + stream: crate::stream::Stream, runtime: tokio::runtime::Handle, framed: bool, ) -> Self { @@ -133,7 +148,7 @@ impl Studio { state.compositor.set_previewing(false); (Registered::new(render, state.compositor.layered()), state.dropped) }; - let controls = Arc::new(Controls::new(engine.clone(), runtime.clone())); + let controls = Arc::new(Controls::new(engine.clone(), stream, runtime.clone())); let mut panels = Panels { engine, runtime, @@ -150,7 +165,9 @@ impl Studio { details: false, left: Tool::Layers, right: Tool::Filters, - launched: kio::clock::now(), + going: None, + ending: None, + stream_form: None, top: false, selection: None, gestures: Gestures::default(), @@ -210,6 +227,21 @@ impl Studio { self.panels.details = true; } + /// Open the go-live sheet, as GO LIVE would. + pub(crate) fn going(&mut self) { + self.panels.open_going(); + } + + /// Whether the go-live sheet's checks have finished, or it is closed. + pub(crate) fn checked(&self) -> bool { + self.panels.going.as_ref().is_none_or(live::Going::done) + } + + /// What the buttons and hotkeys do, such as going live. + pub(crate) fn controls(&self) -> Arc { + self.panels.controls.clone() + } + /// Turn to BUILD and show `tool`, as its tab would. pub(crate) fn tool(&mut self, tool: Tool) { self.panels.page = Page::Build; @@ -308,7 +340,7 @@ impl Studio { .first() .map_or(Verdict::Healthy, |problem| problem.verdict) }; - fx.follow(panels.engine.output.is_some(), snapshot.takes, verdict); + fx.follow(panels.engine.on_air().live().is_some(), snapshot.takes, verdict); panels.window(ui, fx, &snapshot); // A stage not shown hears no input, so it lets go of the pages, as // turning Interact off does. @@ -428,9 +460,12 @@ struct Panels { /// The BUILD page's tool in each column. left: Tool, right: Tool, - /// When the studio started, which it is live from with `--connect`, until - /// going live is its own step (quest/m0/ux/go-live.md). - launched: kio::clock::Instant, + /// The go-live sheet, while open. + going: Option, + /// Since when END STREAM has been held down. + ending: Option, + /// The Stream tab's form, while it has edits not yet saved. + stream_form: Option, /// Whether the Layers tab shows the top layer rather than the scene on /// program. top: bool, diff --git a/rs/moq-studio/src/ui/build.rs b/rs/moq-studio/src/ui/build.rs index 768905fb..ffd5db4c 100644 --- a/rs/moq-studio/src/ui/build.rs +++ b/rs/moq-studio/src/ui/build.rs @@ -106,8 +106,8 @@ impl Panels { .suffix(" px"), ); }); - // It is the live picture, so the accent frame stays while editing it. - let frame = TallyFrame::new(Tally::Air).tag("On air"); + // It is the live picture, so its frame says whether it is on air. + let frame = self.program_frame(); let id = self.program.id; let builder = egui::UiBuilder::new().max_rect(at.expand(10.0)); // Interacting, the pointer belongs to the pages rather than to arranging. diff --git a/rs/moq-studio/src/ui/live.rs b/rs/moq-studio/src/ui/live.rs new file mode 100644 index 00000000..564b40d0 --- /dev/null +++ b/rs/moq-studio/src/ui/live.rs @@ -0,0 +1,1203 @@ +//! Going live from the window: the live control on the title bar, the go-live +//! sheet with where the stream goes and the checks before it does, the health +//! dot and what it opens, and the Stream settings. + +use std::collections::BTreeMap; + +use egui::{Align, Rect, Sense, Stroke, Vec2, pos2, vec2}; +use moq_net::bandwidth::Rate; + +use super::levels::reading; +use super::*; +use crate::engine::OnAir; +use crate::setup::{self, Encoding, Task}; +use crate::stream::{Saved, Stream}; +use crate::{show, uplink}; + +/// How long END STREAM is held down to end the stream. +const HOLD: Duration = Duration::from_millis(1200); + +/// How loud a microphone gets, on the meter's scale, to count as moving. +const MOVING: f32 = 0.2; + +/// How long the microphone check listens before saying it heard nothing. +const LISTEN: Duration = Duration::from_secs(4); + +/// The go-live sheet's checks, run while it is open. +pub(super) struct Going { + /// The canvas the encoder was timed at; another starts the checks over. + canvas: Canvas, + encoder: Task>, + /// Started once the encoder is known, since what it sends is what the + /// connection is measured toward. + uplink: Option>>, + /// The loudest each microphone was since the sheet opened, on the meter's + /// scale. + heard: BTreeMap, + opened: kio::clock::Instant, + /// Whether the confirm was pressed, so the sheet waits on going live. + confirmed: bool, +} + +/// How a check came out. +#[derive(Clone, Copy, PartialEq, Eq)] +enum Outcome { + /// Still checking. + Waiting, + Passed, + /// Failed: going live still works, but viewers would notice. + Failed, + /// Nothing to check, such as a show without a camera. + Skipped, +} + +/// What a failed check offers to do about it. +#[derive(Clone, Copy)] +enum Fix { + /// Send the program at this canvas instead. + Send(Canvas), + /// Measure the connection again. + Again, + /// Open BUILD, where the sources are. + Build, +} + +/// A check's line in the sheet. +struct Check { + mark: Outcome, + icon: Icon, + name: &'static str, + /// What it found, or what is wrong and why, as one sentence. + said: String, + /// The microphone's level, for its meter. + level: Option<(f32, f32)>, + fixes: Vec<(String, Fix)>, +} + +impl Going { + /// Start the checks for the program at `canvas`. + fn new(gpu: crate::engine::Gpu, runtime: &tokio::runtime::Handle, canvas: Canvas) -> Self { + let encoder = Task::spawn(runtime, move || setup::probe(gpu, canvas)) + .unwrap_or_else(|err| Task::Done(Err(format!("cannot start the check: {err}")))); + Self { + canvas, + encoder, + uplink: None, + heard: BTreeMap::new(), + opened: kio::clock::now(), + confirmed: false, + } + } +} + +impl Going { + /// Whether every check that runs in the background has finished. + #[cfg(test)] + pub(super) fn done(&self) -> bool { + matches!(self.encoder, Task::Done(_)) && matches!(self.uplink, Some(Task::Done(_))) + } +} + +/// `canvas` as a broadcaster names it, such as `1080p at 60`. +fn named(canvas: Canvas) -> String { + format!("{}p at {}", canvas.width.min(canvas.height), canvas.framerate) +} + +/// A smaller canvas to send, if there is one worth offering: 720p from +/// anything larger, then 30 frames a second rather than more. +fn smaller(canvas: Canvas) -> Option { + let short = canvas.width.min(canvas.height); + if short > 720 { + let scale = |side: u32| (u64::from(side) * 720 / u64::from(short)) as u32 & !1; + return Some(Canvas { + width: scale(canvas.width), + height: scale(canvas.height), + framerate: canvas.framerate, + }); + } + (canvas.framerate > 30).then_some(Canvas { + framerate: 30, + ..canvas + }) +} + +impl Panels { + /// The live frame's tally and tag: ON AIR in the accent while live, OFF + /// AIR in amber on a neutral frame otherwise. + pub(super) fn program_frame(&self) -> TallyFrame<'static> { + match self.engine.on_air() { + OnAir::Live(_) => TallyFrame::new(Tally::Air).tag("On air"), + OnAir::Ending => TallyFrame::new(Tally::Air).tag("Ending"), + OnAir::Starting => TallyFrame::new(Tally::Off).tag_as("Going live", Tally::Cue), + OnAir::Off => TallyFrame::new(Tally::Off).tag_as("Off air", Tally::Cue), + } + } + + /// The live control: GO LIVE off air, which opens the go-live sheet; the + /// clock on air, which reads END STREAM under the pointer and ends the + /// stream once held down. + pub(super) fn live_control(&mut self, ui: &mut Ui) { + let on_air = self.engine.on_air(); + let font = kit::display_bold(17.0); + let clock_font = kit::mono(14.0); + let painter = ui.painter().clone(); + let end = kit::caps_galley(&painter, "End stream", font.clone(), Color32::WHITE, None); + let live_word = kit::caps_galley(&painter, "Live", font.clone(), Color32::WHITE, None); + let clock_width = painter + .layout_no_wrap("00:00:00".into(), clock_font.clone(), Color32::WHITE) + .size() + .x; + match on_air { + OnAir::Off => { + let key = self.key(&Action::GoLive, ui.ctx()); + // Neither the accent nor red: those say the stream is on air. + let word = kit::caps_galley(&painter, "Go live", font, kit::BG, None); + let size = vec2(word.size().x + 36.0, 30.0); + let (rect, response) = ui.allocate_exact_size(size, Sense::click()); + response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, "Go live")); + let response = kit::tip(response, "Go live", key.as_deref()); + let fill = match response.hovered() { + true => Color32::WHITE, + false => Color32::from_gray(0xe8), + }; + painter.rect_filled(rect, 6, fill); + painter.galley(rect.center() - word.size() / 2.0, word, kit::BG); + if response.clicked() { + self.open_going(); + } + } + OnAir::Starting | OnAir::Ending => { + let text = match on_air { + OnAir::Starting => "Going live", + _ => "Ending", + }; + let word = kit::caps_galley(&painter, text, font, kit::DIM, None); + let size = vec2(word.size().x + 24.0 + 20.0, 30.0); + let (rect, response) = ui.allocate_exact_size(size, Sense::hover()); + let tip = match on_air { + OnAir::Starting => "Dialing the relays and opening the encoders", + _ => "Handing the relays the stream's tail before the sessions close", + }; + kit::tip(response, tip, None); + painter.rect(rect, 6, kit::P2, Stroke::new(1.0, kit::LINE), egui::StrokeKind::Inside); + let spinner = Rect::from_center_size(pos2(rect.left() + 18.0, rect.center().y), Vec2::splat(12.0)); + egui::Spinner::new().size(12.0).color(kit::DIM).paint_at(ui, spinner); + painter.galley( + pos2(rect.left() + 30.0, rect.center().y - word.size().y / 2.0), + word, + kit::DIM, + ); + } + OnAir::Live(live) => { + let key = self.key(&Action::EndStream, ui.ctx()); + let width = (12.0 + live_word.size().x + 10.0 + clock_width + 12.0).max(end.size().x + 24.0); + let (rect, response) = ui.allocate_exact_size(vec2(width, 30.0), Sense::click_and_drag()); + response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, "End stream")); + let relays = live.relays.join(" and "); + let note = format!("Live at {} on {relays}. Hold to end the stream.", live.path); + let held = response.is_pointer_button_down_on(); + let response = kit::tip(response, ¬e, key.as_deref()); + let ending = match (held, self.ending) { + (true, Some(since)) => Some(since), + (true, None) => Some(kio::clock::now()), + (false, _) => None, + }; + self.ending = ending; + let progress = ending.map_or(0.0, |since| since.elapsed().as_secs_f32() / HOLD.as_secs_f32()); + if progress >= 1.0 { + self.ending = None; + if let Err(err) = self.controls.end_stream() { + self.report(Err(err)); + } + } else if ending.is_some() { + ui.ctx().request_repaint(); + } + let glow = egui::Shadow { + offset: [0, 0], + blur: 22, + spread: 0, + color: kit::ACCENT.gamma_multiply(0.4), + }; + painter.add(glow.as_shape(rect, egui::CornerRadius::same(6))); + if response.hovered() || held { + painter.rect_filled(rect, 6, kit::ERR.gamma_multiply(0.35)); + let filled = rect.with_max_x(rect.left() + rect.width() * progress.min(1.0)); + painter.rect_filled(filled, 6, kit::ERR); + painter.rect_stroke(rect, 6, Stroke::new(1.0, kit::ERR), egui::StrokeKind::Inside); + painter.galley(rect.center() - end.size() / 2.0, end, Color32::WHITE); + } else { + painter.rect_filled(rect, 6, kit::ACCENT); + let elapsed = live.since.elapsed(); + let time = painter.layout_no_wrap(super::shell::clock(elapsed), clock_font, Color32::WHITE); + let x = rect.left() + 12.0; + let after = x + live_word.size().x + 10.0; + painter.galley( + pos2(x, rect.center().y - live_word.size().y / 2.0), + live_word, + Color32::WHITE, + ); + let x = after; + painter.galley(pos2(x, rect.center().y - time.size().y / 2.0), time, Color32::WHITE); + } + } + } + } + + /// Open the go-live sheet, starting its checks. + pub(super) fn open_going(&mut self) { + let canvas = self.engine.state.lock().unwrap().collection().canvas; + *self.controls.refused.lock().unwrap() = None; + self.going = Some(Going::new(self.engine.gpu().clone(), &self.runtime, canvas)); + } + + /// The go-live sheet, while open: where the stream goes, each with a + /// switch and its state, the checks as they come in, and one confirm. + pub(super) fn going_sheet(&mut self, ctx: &egui::Context) { + if self.going.is_none() { + return; + } + let on_air = self.engine.on_air(); + // Live: the sheet has done its job. + if on_air.live().is_some() { + self.going = None; + return; + } + ctx.request_repaint_after(Duration::from_millis(100)); + let (show, program, canvas) = { + let state = self.engine.state.lock().unwrap(); + let path = self.engine.autosave.path(); + let show = path + .file_stem() + .unwrap_or(path.as_os_str()) + .to_string_lossy() + .into_owned(); + let program = state.compositor.program_scene().map(str::to_string); + (show, program, state.collection().canvas) + }; + if self.going.as_ref().is_some_and(|going| going.canvas != canvas) { + self.open_going(); + } + self.advance_going(); + let checks = self.checks(); + let mut close = false; + let mut fixes = Vec::new(); + let mut confirm = false; + let mut settings = false; + let refused = self.controls.refused.lock().unwrap().clone(); + let confirmed = self.going.as_ref().is_some_and(|going| going.confirmed); + let id = egui::Id::new("go live"); + let asked = kit::Sheet::new(id, "Go live").show(ctx, |ui| { + let opens = match &program { + Some(scene) => format!("{show} opens on {scene}"), + None => format!("{show} opens on an empty picture"), + }; + ui.label(egui::RichText::new(opens).color(kit::DIM)); + ui.add_space(10.0); + heading(ui, "Where it goes"); + let count = self.destinations(ui, &mut settings); + ui.add_space(10.0); + heading(ui, "Checks"); + for (index, check) in checks.iter().enumerate() { + kit::popover_row(ui, index + 1 == checks.len(), |ui| { + if let Some(fix) = check_row(ui, check) { + fixes.push(fix); + } + }); + } + ui.add_space(12.0); + if let Some(refused) = &refused { + ui.horizontal(|ui| { + ui.add(Icon::Warning.image(16.0, kit::ERR)); + ui.add(egui::Label::new(egui::RichText::new(refused).color(kit::TEXT)).wrap()); + }); + ui.add_space(8.0); + } + let waiting = confirmed && matches!(on_air, OnAir::Starting); + let text = match (waiting, count) { + (true, _) => "Going live".to_string(), + (false, 0) => "Switch a destination on".to_string(), + (false, count) => format!("Go live to {count}"), + }; + let enabled = count > 0 && on_air == OnAir::Off; + confirm = confirm_button(ui, &text, enabled, waiting).clicked(); + }); + close |= asked; + if settings { + self.setting = Some(Setting::Stream); + close = true; + } + for fix in fixes { + match fix { + Fix::Send(canvas) => { + let label = format!("Send {} instead", named(canvas)); + let mut state = self.engine.state.lock().unwrap(); + let result = super::edit(&mut state, label, None, |draft| draft.set_canvas(canvas)); + drop(state); + self.check(result); + } + Fix::Again => { + if let Some(going) = &mut self.going { + going.uplink = None; + } + } + Fix::Build => { + self.page = Page::Build; + close = true; + } + } + } + if confirm { + match self.controls.go_live() { + Ok(_) => { + if let Some(going) = &mut self.going { + going.confirmed = true; + } + } + Err(err) => *self.controls.refused.lock().unwrap() = Some(format!("{err:#}")), + } + } + if close { + self.going = None; + } + } + + /// Collect the checks that finished, and start measuring the connection + /// once the encoder says what it sends. + fn advance_going(&mut self) { + let Some(going) = &mut self.going else { return }; + going.encoder.poll(); + if going.uplink.is_none() + && let Task::Done(encoder) = &going.encoder + { + going.uplink = Some(match encoder { + Ok(encoding) => { + // Up to past what it sends, so a connection that carries + // it says so rather than stopping at its rate. + let ceiling = encoding.total().scaled(1.0 / setup::headroom()); + measure(&self.controls, &self.runtime, ceiling) + } + Err(_) => Task::Done(Err("nothing encodes, so nothing would be sent".into())), + }); + } + if let Some(uplink) = &mut going.uplink { + uplink.poll(); + } + } + + /// Each destination, with its switch and its state; how many are on. + fn destinations(&mut self, ui: &mut Ui, settings: &mut bool) -> usize { + let (relay, failover) = { + let stream = self.controls.stream.lock().unwrap(); + (stream.relay().cloned(), stream.failover().cloned()) + }; + if relay.is_none() && failover.is_none() { + kit::popover_row(ui, true, |ui| { + ui.label("No relay yet. Add the one the stream goes to."); + ui.with_layout(egui::Layout::right_to_left(Align::Center), |ui| { + *settings = ui.button("Set one up").clicked(); + }); + }); + return 0; + } + let watched = self.engine.watched(); + let mut switched = *self.controls.switched.lock().unwrap(); + let rows = [ + ("Relay", relay, &mut switched.relay), + ("Failover relay", failover, &mut switched.failover), + ]; + let rows: Vec<_> = rows + .into_iter() + .filter_map(|(name, url, on)| Some((name, url?, on))) + .collect(); + let count = rows.len(); + let mut on_count = 0; + for (index, (name, url, on)) in rows.into_iter().enumerate() { + let endpoint = crate::engine::air::endpoint(&url); + let state = watched.iter().find(|(relay, _)| relay.endpoint == endpoint); + let (dot, said) = match (*on, state) { + (false, _) => (None, "Off".to_string()), + (true, None) => (Some(kit::DIM), "Not dialed yet".to_string()), + (true, Some((relay, rtt))) => match &relay.state { + health::State::Connected => ( + Some(kit::OK), + match rtt { + Some(rtt) => format!("Connected, {} ms away", rtt.as_millis()), + None => "Connected".into(), + }, + ), + health::State::Connecting => (Some(kit::DIM), "Connecting".into()), + health::State::Disconnected(why) => (Some(kit::ERR), format!("Cannot reach it: {why}")), + }, + }; + if *on { + on_count += 1; + } + kit::popover_row(ui, index + 1 == count, |ui| { + ui.add(kit::Toggle::new(on)); + let (at, _) = ui.allocate_exact_size(vec2(8.0, 8.0), Sense::hover()); + match dot { + Some(dot) => ui.painter().circle_filled(at.center(), 4.0, dot), + None => ui + .painter() + .circle_stroke(at.center(), 3.5, Stroke::new(1.0, kit::FAINT)), + }; + ui.label(egui::RichText::new(name).font(kit::ui_strong(13.0)).color(kit::TEXT)) + .on_hover_text(url.as_str()); + ui.with_layout(egui::Layout::right_to_left(Align::Center), |ui| { + ui.add(egui::Label::new(egui::RichText::new(said).color(kit::DIM)).truncate()); + }); + }); + } + let changed = switched != *self.controls.switched.lock().unwrap(); + *self.controls.switched.lock().unwrap() = switched; + // The connection is measured to the first relay switched on. + if changed && let Some(going) = &mut self.going { + going.uplink = None; + } + on_count + } + + /// The checks, as they stand. + fn checks(&mut self) -> Vec { + let engine = self.engine.clone(); + let state = engine.state.lock().unwrap(); + let collection = state.collection(); + let now = kio::clock::now(); + let Some(going) = &mut self.going else { + return Vec::new(); + }; + let mut checks = Vec::new(); + + // Each camera in the show has a picture. + let cameras: Vec<_> = collection + .sources + .iter() + .filter(|(_, source)| matches!(source, Source::Camera { .. })) + .map(|(name, _)| { + let failed = state.compositor.error(name).map(|err| err.to_string()); + let status = state.sources.get(name).map(|feed| feed.status()); + (name.clone(), failed, status) + }) + .collect(); + let blank = cameras + .iter() + .find(|(_, failed, status)| failed.is_some() || !matches!(status, Some(Status::Live))); + checks.push(match (cameras.first(), blank) { + (None, _) => Check { + mark: Outcome::Skipped, + icon: Icon::Camera, + name: "Camera", + said: "This show has no camera".into(), + level: None, + fixes: Vec::new(), + }, + (Some((name, ..)), None) => Check { + mark: Outcome::Passed, + icon: Icon::Camera, + name: "Camera", + said: format!("{name} has a picture"), + level: None, + fixes: Vec::new(), + }, + (Some(_), Some((name, failed, status))) => { + let why = match (failed, status) { + (Some(failed), _) => format!("{name} has no picture: {failed}."), + (None, Some(Status::Failed(why))) => format!("{name} has no picture: {why}."), + (None, Some(Status::Starting)) | (None, None) => format!("{name} is still starting."), + (None, _) => format!("{name} has no picture. Check it is plugged in and not in use."), + }; + Check { + mark: Outcome::Failed, + icon: Icon::Camera, + name: "Camera", + said: why, + level: None, + fixes: vec![("Open BUILD".into(), Fix::Build)], + } + } + }); + + // Each microphone's level moves. + let microphones: Vec = collection + .sources + .iter() + .filter(|(_, source)| matches!(source, Source::Microphone { .. })) + .map(|(name, _)| name.clone()) + .collect(); + for name in µphones { + let (level, _) = reading(self.levels.sound(name)); + let heard = going.heard.entry(name.clone()).or_default(); + *heard = heard.max(level); + } + let moving = microphones + .iter() + .find(|name| going.heard.get(*name).is_some_and(|heard| *heard >= MOVING)); + let listened = now.saturating_duration_since(going.opened) >= LISTEN; + let shown = moving.or(microphones.first()); + let level = shown.map(|name| reading(self.levels.sound(name))); + checks.push(match (shown, moving, listened) { + (None, ..) => Check { + mark: Outcome::Skipped, + icon: Icon::Mic, + name: "Microphone", + said: "This show has no microphone".into(), + level: None, + fixes: Vec::new(), + }, + (Some(name), Some(_), _) => Check { + mark: Outcome::Passed, + icon: Icon::Mic, + name: "Microphone", + said: format!("{name} is moving"), + level, + fixes: Vec::new(), + }, + (Some(name), None, false) => Check { + mark: Outcome::Waiting, + icon: Icon::Mic, + name: "Microphone", + said: format!("Listening to {name}; say something"), + level, + fixes: Vec::new(), + }, + (Some(name), None, true) => Check { + mark: Outcome::Failed, + icon: Icon::Mic, + name: "Microphone", + said: format!("{name} has been silent. Speak, or check it is not muted in the sound panel."), + level, + fixes: Vec::new(), + }, + }); + + // The encoder keeps up with the canvas. + let canvas = going.canvas; + let send = smaller(canvas).map(|smaller| (format!("Send {} instead", named(smaller)), Fix::Send(smaller))); + let encoding = match &going.encoder { + Task::Done(Ok(encoding)) => Some(encoding.clone()), + _ => None, + }; + checks.push(match &going.encoder { + Task::Running(_) => Check { + mark: Outcome::Waiting, + icon: Icon::Encoder, + name: "Encoder", + said: format!("Timing {}", named(canvas)), + level: None, + fixes: Vec::new(), + }, + Task::Done(Ok(encoding)) if encoding.keeps_up(canvas) => Check { + mark: Outcome::Passed, + icon: Icon::Encoder, + name: "Encoder", + said: format!("Keeps up with {}", named(canvas)), + level: None, + fixes: Vec::new(), + }, + Task::Done(Ok(encoding)) => Check { + mark: Outcome::Failed, + icon: Icon::Encoder, + name: "Encoder", + said: format!( + "The encoder takes {} ms a frame, too slow for {}. Viewers would see it stutter.", + encoding.frame.as_millis(), + named(canvas) + ), + level: None, + fixes: send.clone().into_iter().collect(), + }, + Task::Done(Err(err)) => Check { + mark: Outcome::Failed, + icon: Icon::Encoder, + name: "Encoder", + said: format!("Nothing encodes {} here: {err}.", named(canvas)), + level: None, + fixes: send.clone().into_iter().collect(), + }, + }); + + // The connection carries what the stream sends. + let again = ("Check again".to_string(), Fix::Again); + checks.push(match (&going.uplink, &encoding) { + (None, _) | (Some(Task::Running(_)), _) => Check { + mark: Outcome::Waiting, + icon: Icon::Uplink, + name: "Connection", + said: "Measuring the connection to the relay".into(), + level: None, + fixes: Vec::new(), + }, + (Some(Task::Done(Err(err))), _) => Check { + mark: Outcome::Failed, + icon: Icon::Uplink, + name: "Connection", + said: format!("The connection was not measured: {err}."), + level: None, + fixes: vec![again], + }, + (Some(Task::Done(Ok(_))), None) => Check { + mark: Outcome::Skipped, + icon: Icon::Uplink, + name: "Connection", + said: "Measured, but nothing encodes to compare it with".into(), + level: None, + fixes: Vec::new(), + }, + (Some(Task::Done(Ok(carries))), Some(encoding)) => { + let needs = encoding.total(); + match carries.scaled(setup::headroom()) >= needs { + true => Check { + mark: Outcome::Passed, + icon: Icon::Uplink, + name: "Connection", + said: format!( + "Carries {}, and this stream needs {}", + health::rate(*carries), + health::rate(needs) + ), + level: None, + fixes: Vec::new(), + }, + false => Check { + mark: Outcome::Failed, + icon: Icon::Uplink, + name: "Connection", + said: format!( + "The connection carries {} and this stream needs {}. Viewers would see it stall.", + health::rate(*carries), + health::rate(needs) + ), + level: None, + fixes: send.into_iter().chain([again]).collect(), + }, + } + } + }); + checks + } + + /// The stream's health as one dot, its name beside it unless `compact`, + /// opening the worst problem, every destination, the viewers, and the + /// encoder, and the details from there. + pub(super) fn health_dot(&mut self, ui: &mut Ui, fx: &mut Fx, compact: bool) { + let on_air = self.engine.on_air(); + let watched = self.engine.watched(); + let report = self.engine.health.lock().unwrap(); + let worst = report + .problems + .first() + .map_or(Verdict::Healthy, |problem| problem.verdict); + // A problem shows even off air, such as a failed source. + let (name, dot) = match (worst, on_air.live().is_some(), watched.is_empty()) { + (Verdict::Unhealthy, ..) => ("Unhealthy", kit::ERR), + (Verdict::Degraded, ..) => ("Degraded", kit::CUE), + (_, false, true) => ("No relay", kit::DIM), + (_, false, false) => ("Ready", kit::OK), + (Verdict::Healthy, true, _) => ("Healthy", kit::OK), + (Verdict::Unknown, true, _) => ("Starting", kit::DIM), + }; + let mark = fx.on().then(|| crate::fx::Mark::new(ui.painter())); + let text = if compact { "" } else { name }; + let pill = ui.add(kit::Pill::new(text).dot(dot).clickable()); + let pill = kit::tip(pill, &format!("Health: {name}"), None); + if let Some(mark) = mark { + fx.health(&mark.around(pill.rect).inset(2.0)); + } + let mut details = false; + let mut settings = false; + kit::popover(&pill).show(|ui| { + ui.set_width(400.0); + let row = |ui: &mut Ui, dot: Option, name: &str, note: &str, value: &str| { + kit::popover_row(ui, false, |ui| { + let (at, _) = ui.allocate_exact_size(vec2(8.0, 8.0), Sense::hover()); + match dot { + Some(dot) => ui.painter().circle_filled(at.center(), 4.0, dot), + None => ui + .painter() + .circle_stroke(at.center(), 3.5, Stroke::new(1.0, kit::FAINT)), + }; + ui.label(egui::RichText::new(name).color(kit::TEXT)); + ui.add(egui::Label::new(egui::RichText::new(note).color(kit::DIM)).truncate()); + ui.with_layout(egui::Layout::right_to_left(Align::Center), |ui| { + ui.label(egui::RichText::new(value).font(kit::mono(12.0)).color(kit::TEXT)) + }); + }); + }; + // The worst problem first, on a card of its own. + if let Some(problem) = report.problems.first() { + let color = super::color(problem.verdict); + egui::Frame::new() + .fill(color.gamma_multiply(0.08)) + .stroke(Stroke::new(1.0, color)) + .corner_radius(10) + .inner_margin(12) + .show(ui, |ui| { + ui.set_width(ui.available_width()); + ui.horizontal_top(|ui| { + ui.add(Icon::Warning.image(18.0, color)); + ui.add( + egui::Label::new( + egui::RichText::new(&problem.cause) + .font(kit::ui_strong(14.0)) + .color(kit::TEXT), + ) + .wrap(), + ); + }); + }); + for problem in report.problems.iter().skip(1) { + row(ui, Some(super::color(problem.verdict)), &problem.cause, "", ""); + } + } + heading(ui, "Destinations"); + match on_air.live() { + Some(_) => { + for relay in &report.relays { + let (dot, state) = match &relay.state { + health::State::Connecting => (kit::DIM, "connecting"), + health::State::Connected => (kit::OK, "connected"), + health::State::Disconnected(_) => (kit::ERR, "unreachable"), + }; + let rtt = match &report.uplink.relay { + Some(endpoint) if *endpoint == relay.endpoint => report.uplink.rtt, + _ => None, + }; + let rtt = rtt.map(|rtt| format!("{} ms", rtt.as_millis())).unwrap_or_default(); + row(ui, Some(dot), &relay.endpoint, state, &rtt); + } + } + None if watched.is_empty() => { + kit::popover_row(ui, false, |ui| { + ui.label("No relay yet."); + ui.with_layout(egui::Layout::right_to_left(Align::Center), |ui| { + settings = ui.button("Set one up").clicked(); + }); + }); + } + None => { + for (relay, rtt) in &watched { + let (dot, state) = match &relay.state { + health::State::Connected => (Some(kit::OK), "standing by"), + health::State::Connecting => (None, "connecting"), + health::State::Disconnected(_) => (Some(kit::ERR), "unreachable"), + }; + let rtt = rtt.map(|rtt| format!("{} ms", rtt.as_millis())).unwrap_or_default(); + row(ui, dot, &relay.endpoint, state, &rtt); + } + } + } + heading(ui, "Tracks and viewers"); + let uplink = &report.uplink; + let media = uplink.media.map(health::rate).unwrap_or_default(); + row(ui, None, "Sent", "every track, to the relay", &media); + let watching = report + .broadcasts + .first() + .and_then(|program| program.viewers.watching) + .map(|watching| watching.to_string()); + let watching_note = match on_air.live() { + Some(_) => "", + None => "off air", + }; + row(ui, None, "Watching", watching_note, watching.as_deref().unwrap_or("-")); + let encoder = self.engine.stats.video.encoder(); + let encoder_note = match &encoder { + Some(_) => "", + None => "opens on air", + }; + row(ui, None, "Encoder", encoder_note, encoder.as_deref().unwrap_or("")); + ui.add_space(4.0); + details = ui.button("Details").clicked(); + }); + drop(report); + if details { + self.details = true; + } + if settings { + self.setting = Some(Setting::Stream); + } + } + + /// Settings, Stream: the relay and its token, a failover relay, the + /// broadcast's name, and on-demand encoding, kept beside the show. A + /// setting a flag overrides for this run says so. + pub(super) fn stream_settings(&mut self, ui: &mut Ui) { + let stream = self.controls.stream.lock().unwrap().clone(); + let overridden = stream.overridden(); + let form = self.stream_form.get_or_insert_with(|| Form::new(&stream)); + if let Some(saving) = &mut form.saving + && let Some(saved) = saving.poll() + { + match saved.clone() { + Ok(saved) => { + *self.controls.stream.lock().unwrap() = saved.clone(); + show::watch(&self.engine, &saved, &self.runtime); + *form = Form::new(&saved); + form.note = Some("Saved. It applies the next time you go live.".into()); + } + Err(err) => { + form.saving = None; + form.note = Some(err); + } + } + } + let busy = form.saving.is_some(); + if busy { + ui.ctx().request_repaint_after(Duration::from_millis(100)); + } + ui.label( + egui::RichText::new(format!( + "Kept beside the show, in {}. Tokens go in the system's credential store, never in a file.", + stream.path().display() + )) + .color(kit::DIM), + ); + ui.add_space(8.0); + let flagged = |ui: &mut Ui, flag: &str| { + ui.label(egui::RichText::new(format!("{flag} overrides this for this run")).color(kit::CUE)); + }; + ui.add_enabled_ui(!busy, |ui| { + egui::Grid::new("stream settings") + .num_columns(2) + .spacing(vec2(14.0, 10.0)) + .show(ui, |ui| { + ui.label("Relay"); + ui.vertical(|ui| { + ui.add( + egui::TextEdit::singleline(&mut form.relay) + .hint_text("https://relay.example/anon") + .desired_width(360.0), + ); + if overridden.relay { + flagged(ui, "--connect"); + } + }); + ui.end_row(); + ui.label("Token"); + ui.vertical(|ui| { + ui.add( + egui::TextEdit::singleline(&mut form.relay_token) + .password(true) + .hint_text("Leave empty to keep the saved one") + .desired_width(360.0), + ); + ui.checkbox(&mut form.forget_relay_token, "Forget the saved token"); + if overridden.token { + flagged(ui, "--connect-token"); + } + }); + ui.end_row(); + ui.label("Failover relay"); + ui.vertical(|ui| { + ui.add( + egui::TextEdit::singleline(&mut form.failover) + .hint_text("A second relay viewers resume from") + .desired_width(360.0), + ); + if overridden.failover { + flagged(ui, "--failover"); + } + }); + ui.end_row(); + ui.label("Its token"); + ui.vertical(|ui| { + ui.add( + egui::TextEdit::singleline(&mut form.failover_token) + .password(true) + .hint_text("Leave empty to keep the saved one") + .desired_width(360.0), + ); + ui.checkbox(&mut form.forget_failover_token, "Forget the saved token"); + }); + ui.end_row(); + ui.label("Broadcast name"); + ui.vertical(|ui| { + ui.add( + egui::TextEdit::singleline(&mut form.broadcast) + .hint_text(crate::stream::BROADCAST) + .desired_width(360.0), + ); + if overridden.broadcast { + flagged(ui, "--broadcast"); + } + }); + ui.end_row(); + ui.label("On demand"); + ui.vertical(|ui| { + ui.add(kit::Toggle::new(&mut form.on_demand).label("Encode the full size only while watched")); + ui.add( + egui::Label::new( + egui::RichText::new( + "Saves the work, but a late viewer gets nothing from before they arrived.", + ) + .color(kit::DIM), + ) + .wrap(), + ); + if overridden.on_demand { + flagged(ui, "--on-demand"); + } + }); + ui.end_row(); + }); + }); + ui.add_space(10.0); + ui.horizontal(|ui| { + let edited = form.edited(stream.saved()); + if ui.add_enabled(edited && !busy, egui::Button::new("Save")).clicked() { + match form.saved(stream.saved()) { + Ok(saved) => { + let tokens = form.tokens(); + form.saving = Some(save(stream, saved, tokens, &self.runtime)); + form.note = None; + } + Err(err) => form.note = Some(err), + } + } + if ui.add_enabled(edited && !busy, egui::Button::new("Revert")).clicked() { + let stream = self.controls.stream.lock().unwrap().clone(); + *form = Form::new(&stream); + } + if busy { + ui.spinner(); + } + if let Some(note) = &form.note { + ui.label(egui::RichText::new(note).color(kit::DIM)); + } + }); + } +} + +/// Measure the connection to the first relay switched on toward `ceiling`, +/// reading its token on the task's own thread, since the credential store +/// blocks. +fn measure(controls: &Controls, runtime: &tokio::runtime::Handle, ceiling: Rate) -> Task> { + let stream = controls.stream.lock().unwrap().clone(); + let switched = *controls.switched.lock().unwrap(); + let handle = runtime.clone(); + let task = Task::spawn(runtime, move || { + let relays = { + // Each client binds its socket on the runtime. + let _runtime = handle.enter(); + stream.relays(switched) + }; + let path = stream.broadcast().to_string(); + async move { + let relays = relays.map_err(|err| format!("{err:#}"))?; + let relay = relays.into_iter().next().ok_or("no relay is switched on")?; + uplink::measure(&relay.client, relay.url, &path, ceiling, uplink::WINDOW) + .await + .map_err(|err| format!("{err:#}")) + } + }); + task.unwrap_or_else(|err| Task::Done(Err(format!("cannot start the measurement: {err}")))) +} + +/// A section's heading in a sheet or popover. +fn heading(ui: &mut Ui, text: &str) { + ui.add_space(6.0); + ui.label(kit::caps(text, kit::display_bold(11.0)).color(kit::FAINT)); + ui.add_space(2.0); +} + +/// A check's line: its mark, its icon and name, what it found, and a button +/// for each fix; the fix pressed, if any. +fn check_row(ui: &mut Ui, check: &Check) -> Option { + let mut pressed = None; + ui.vertical(|ui| { + ui.horizontal(|ui| { + let (at, _) = ui.allocate_exact_size(Vec2::splat(20.0), Sense::hover()); + let painter = ui.painter(); + match check.mark { + Outcome::Waiting => { + egui::Spinner::new() + .size(14.0) + .color(kit::DIM) + .paint_at(ui, at.shrink(3.0)); + } + Outcome::Passed => { + painter.circle_filled(at.center(), 10.0, kit::OK.gamma_multiply(0.2)); + Icon::Check.paint(ui, at.shrink(4.0), 12.0, kit::OK); + } + Outcome::Failed => { + painter.circle_filled(at.center(), 10.0, kit::CUE); + Icon::Close.paint(ui, at.shrink(4.0), 12.0, kit::ON_CUE); + } + Outcome::Skipped => { + painter.circle_stroke(at.center(), 9.0, Stroke::new(1.0, kit::FAINT)); + } + } + if check.mark == Outcome::Failed { + ui.add( + egui::Label::new( + egui::RichText::new(&check.said) + .font(kit::ui_strong(13.0)) + .color(kit::TEXT), + ) + .wrap(), + ); + return; + } + ui.add(check.icon.image(14.0, kit::DIM)); + ui.label( + egui::RichText::new(check.name) + .font(kit::ui_strong(13.0)) + .color(kit::TEXT), + ); + ui.with_layout(egui::Layout::right_to_left(Align::Center), |ui| { + ui.add(egui::Label::new(egui::RichText::new(&check.said).color(kit::DIM)).truncate()); + if let Some((level, peak)) = check.level { + ui.add(kit::Meter::new(level, peak).run(kit::Run::Across, 80.0, 8.0)); + } + }); + }); + if !check.fixes.is_empty() { + ui.horizontal(|ui| { + ui.add_space(28.0); + for (index, (label, fix)) in check.fixes.iter().enumerate() { + let button = match index { + 0 => egui::Button::new(egui::RichText::new(label).color(kit::ON_CUE)).fill(kit::CUE), + _ => egui::Button::new(label), + }; + if ui.add(button).clicked() { + pressed = Some(*fix); + } + } + }); + } + }); + pressed +} + +/// The sheet's confirm: one wide light button, neither the accent nor red. +fn confirm_button(ui: &mut Ui, text: &str, enabled: bool, waiting: bool) -> egui::Response { + let size = vec2(ui.available_width(), 54.0); + let sense = if enabled { Sense::click() } else { Sense::hover() }; + let (rect, response) = ui.allocate_exact_size(size, sense); + response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, enabled, text)); + let (fill, ink) = match (enabled, response.hovered()) { + (true, true) => (Color32::WHITE, kit::BG), + (true, false) => (Color32::from_gray(0xe8), kit::BG), + (false, _) => (kit::P3, kit::DIM), + }; + let painter = ui.painter(); + painter.rect_filled(rect, 8, fill); + let galley = kit::caps_galley(painter, text, kit::display(22.0), ink, None); + let mut at = rect.center() - galley.size() / 2.0; + if waiting { + let spinner = Rect::from_center_size(pos2(at.x - 14.0, rect.center().y), Vec2::splat(16.0)); + egui::Spinner::new().size(16.0).color(kit::DIM).paint_at(ui, spinner); + at.x += 6.0; + } + ui.painter().galley(at, galley, ink); + response +} + +/// The Stream tab's form. +pub(super) struct Form { + relay: String, + relay_token: String, + forget_relay_token: bool, + failover: String, + failover_token: String, + forget_failover_token: bool, + broadcast: String, + on_demand: bool, + saving: Option>>, + /// How the last save went, or why it was refused. + note: Option, +} + +/// A token to keep for a relay, or `None` to forget its saved one. +type Token = (url::Url, Option); + +impl Form { + /// The form holding what `stream` saved, not what the flags set. + fn new(stream: &Stream) -> Self { + let saved = stream.saved(); + let text = |url: &Option| url.as_ref().map(url::Url::to_string).unwrap_or_default(); + Self { + relay: text(&saved.relay), + relay_token: String::new(), + forget_relay_token: false, + failover: text(&saved.failover), + failover_token: String::new(), + forget_failover_token: false, + broadcast: saved.broadcast.clone().unwrap_or_default(), + on_demand: saved.on_demand, + saving: None, + note: None, + } + } + + /// What the form would save over `saved`, or why it cannot. + fn saved(&self, saved: &Saved) -> Result { + let url = |text: &str, name: &str| -> Result, String> { + match text.trim() { + "" => Ok(None), + text => text + .parse() + .map(Some) + .map_err(|err| format!("The {name} address is not a URL: {err}.")), + } + }; + let broadcast = self.broadcast.trim(); + Ok(Saved { + relay: url(&self.relay, "relay")?, + failover: url(&self.failover, "failover relay")?, + broadcast: (!broadcast.is_empty()).then(|| broadcast.to_string()), + on_demand: self.on_demand, + ..saved.clone() + }) + } + + /// Whether the form holds anything to save over `saved`. + fn edited(&self, saved: &Saved) -> bool { + let tokens = !self.relay_token.is_empty() + || !self.failover_token.is_empty() + || self.forget_relay_token + || self.forget_failover_token; + tokens || self.saved(saved).is_ok_and(|form| form != *saved) || self.saved(saved).is_err() + } + + /// The tokens typed or forgotten, by the relay they go with. + fn tokens(&self) -> Vec { + let mut tokens = Vec::new(); + for (url, token, forget) in [ + (&self.relay, &self.relay_token, self.forget_relay_token), + (&self.failover, &self.failover_token, self.forget_failover_token), + ] { + let Ok(url) = url.trim().parse::() else { + continue; + }; + match (token.trim(), forget) { + ("", true) => tokens.push((url, None)), + ("", false) => {} + (token, _) => tokens.push((url, Some(token.to_string()))), + } + } + tokens + } +} + +/// Keep `tokens` and save `saved` as `stream`'s, on a thread of their own, +/// since the credential store blocks. +fn save( + mut stream: Stream, + saved: Saved, + tokens: Vec, + runtime: &tokio::runtime::Handle, +) -> Task> { + let task = Task::spawn(runtime, move || { + let result = (|| -> anyhow::Result { + for (url, token) in &tokens { + stream.credentials().set(url, token.as_deref())?; + } + stream.save(saved)?; + Ok(stream) + })(); + let result = result.map_err(|err| format!("{err:#}")); + async move { result } + }); + task.unwrap_or_else(|err| Task::Done(Err(format!("cannot save: {err}")))) +} diff --git a/rs/moq-studio/src/ui/settings.rs b/rs/moq-studio/src/ui/settings.rs index 89ef9ce5..15229588 100644 --- a/rs/moq-studio/src/ui/settings.rs +++ b/rs/moq-studio/src/ui/settings.rs @@ -52,14 +52,15 @@ impl Panels { let count = |value: &std::sync::atomic::AtomicU64| value.load(Ordering::Relaxed); let watched = stats.video.watched.load(Ordering::Relaxed); + let on_air = self.engine.on_air(); egui::Grid::new("output").show(ui, |ui| { - match &self.engine.output { - Some(output) => { + match on_air.live() { + Some(live) => { ui.label("Broadcast"); - ui.label(&output.path); + ui.label(&live.path); ui.end_row(); ui.label("Encoding"); - ui.label(match (output.on_demand, watched) { + ui.label(match (live.on_demand, watched) { (false, _) => "the canvas size always, half size while watched", (true, true) => "while watched; watched now", (true, false) => "while watched; idle now", @@ -67,8 +68,8 @@ impl Panels { ui.end_row(); } None => { - ui.label("Relay"); - ui.label("none; start with --connect to publish"); + ui.label("On air"); + ui.label("no; GO LIVE sends the program to the relays in Settings, Stream"); ui.end_row(); ui.label("Encoding"); ui.label("only the recording's encoder, while recording"); @@ -104,7 +105,7 @@ impl Panels { for (name, video) in stats.published() { ui.separator(); ui.strong(format!("Scene `{name}`")); - if let Some(output) = &self.engine.output { + if let Some(live) = on_air.live() { let state = self.engine.state.lock().unwrap(); let audio = state .collection() @@ -112,7 +113,7 @@ impl Panels { .unwrap_or_default() .to_string(); drop(state); - ui.label(format!("Broadcast {}/{name}, with audio scene `{audio}`", output.path)); + ui.label(format!("Broadcast {}/{name}, with audio scene `{audio}`", live.path)); } ui.label(format!( "Encoder: {}", diff --git a/rs/moq-studio/src/ui/shell.rs b/rs/moq-studio/src/ui/shell.rs index 00710b25..2bb3acbe 100644 --- a/rs/moq-studio/src/ui/shell.rs +++ b/rs/moq-studio/src/ui/shell.rs @@ -203,6 +203,7 @@ impl Panels { self.toast(ui.ctx(), layout.stage); self.settings(ui.ctx(), fx, layout.stage); self.details(ui.ctx(), layout.stage); + self.going_sheet(ui.ctx()); // macOS keeps its own frame's edges, and resizes by them. if self.framed && !cfg!(target_os = "macos") { edges(ui, window); @@ -244,10 +245,9 @@ impl Panels { let id = self.program.id; let canvas = self.program_drawn; let builder = UiBuilder::new().max_rect(picture.expand(10.0)); + let frame = self.program_frame(); ui.scope_builder(builder, |ui| { - TallyFrame::new(Tally::Air) - .tag("On air") - .show(ui, fx, |ui| super::picture(ui, id, canvas, Sense::hover())) + frame.show(ui, fx, |ui| super::picture(ui, id, canvas, Sense::hover())) }) .inner } @@ -462,72 +462,6 @@ impl Panels { } } - /// The stream's health as one dot, its name beside it unless `compact`, - /// with each relay, the viewers, the encoder, and each problem in its - /// popover, which opens the details. - fn health_dot(&mut self, ui: &mut Ui, fx: &mut Fx, compact: bool) { - let report = self.engine.health.lock().unwrap(); - let worst = report - .problems - .first() - .map_or(Verdict::Healthy, |problem| problem.verdict); - // A problem shows even when not publishing, such as a failed source. - let (name, dot) = match (worst, report.relays.is_empty()) { - (Verdict::Unhealthy, _) => ("Unhealthy", kit::ERR), - (Verdict::Degraded, _) => ("Degraded", kit::CUE), - (_, true) => ("Not live", kit::DIM), - (Verdict::Healthy, false) => ("Healthy", kit::OK), - (Verdict::Unknown, false) => ("Starting", kit::DIM), - }; - let mark = fx.on().then(|| Mark::new(ui.painter())); - let text = if compact { "" } else { name }; - let pill = ui.add(kit::Pill::new(text).dot(dot).clickable()); - let pill = kit::tip(pill, &format!("Health: {name}"), None); - if let Some(mark) = mark { - fx.health(&mark.around(pill.rect).inset(2.0)); - } - let mut details = false; - kit::popover(&pill).show(|ui| { - let row = |ui: &mut Ui, dot: Option, name: &str, value: &str| { - kit::popover_row(ui, false, |ui| { - let (at, _) = ui.allocate_exact_size(vec2(8.0, 8.0), Sense::hover()); - if let Some(dot) = dot { - ui.painter().circle_filled(at.center(), 4.0, dot); - } - ui.add(egui::Label::new(name).wrap()); - ui.with_layout(egui::Layout::right_to_left(Align::Center), |ui| { - ui.label(egui::RichText::new(value).font(kit::mono(12.0)).color(kit::TEXT)) - }); - }); - }; - if report.relays.is_empty() { - row(ui, None, "Not publishing; start with --connect", ""); - } - for relay in &report.relays { - let (dot, state) = match &relay.state { - health::State::Connecting => (kit::DIM, "connecting"), - health::State::Connected => (kit::OK, "connected"), - health::State::Disconnected(_) => (kit::ERR, "unreachable"), - }; - row(ui, Some(dot), &relay.endpoint, state); - } - if let Some(watching) = report.broadcasts.first().and_then(|program| program.viewers.watching) { - row(ui, None, "Watching", &watching.to_string()); - } - let encoder = self.engine.stats.video.encoder(); - row(ui, None, "Encoder", encoder.as_deref().unwrap_or("not open")); - for problem in &report.problems { - row(ui, Some(color(problem.verdict)), &problem.cause, ""); - } - ui.add_space(4.0); - details = ui.button("Details").clicked(); - }); - drop(report); - if details { - self.details = true; - } - } - /// Start or stop recording, pulsing while it records. fn record_button(&mut self, ui: &mut Ui, fx: &mut Fx) { let status = self.engine.recorder.status().filter(|status| !status.done); @@ -567,51 +501,6 @@ impl Panels { } } - /// The live control: LIVE with the clock while the studio publishes, or - /// not live without `--connect`. Ending the stream comes with going live - /// (quest/m0/ux/go-live.md), so it has no END STREAM face yet. - fn live_control(&mut self, ui: &mut Ui) { - let Some(output) = &self.engine.output else { - let galley = kit::caps_galley(ui.painter(), "Not live", kit::display_bold(15.0), kit::DIM, None); - let (rect, response) = ui.allocate_exact_size(vec2(galley.size().x + 24.0, 30.0), Sense::hover()); - kit::tip(response, "Not live: start the studio with --connect to publish", None); - ui.painter() - .rect(rect, 6, kit::P2, Stroke::new(1.0, kit::LINE), egui::StrokeKind::Inside); - ui.painter() - .galley(rect.center() - galley.size() / 2.0, galley, kit::DIM); - return; - }; - let elapsed = kio::clock::now().saturating_duration_since(self.launched); - let word = kit::caps_galley(ui.painter(), "Live", kit::display_bold(17.0), Color32::WHITE, None); - let time = ui - .painter() - .layout_no_wrap(clock(elapsed), kit::mono(14.0), Color32::WHITE); - let width = 12.0 + word.size().x + 10.0 + time.size().x + 12.0; - let (rect, response) = ui.allocate_exact_size(vec2(width, 30.0), Sense::hover()); - kit::tip( - response, - &format!("Live at {} since the studio started", output.path), - None, - ); - let painter = ui.painter(); - let glow = egui::Shadow { - offset: [0, 0], - blur: 22, - spread: 0, - color: kit::ACCENT.gamma_multiply(0.4), - }; - painter.add(glow.as_shape(rect, egui::CornerRadius::same(6))); - painter.rect_filled(rect, 6, kit::ACCENT); - let x = rect.left() + 12.0; - painter.galley( - pos2(x, rect.center().y - word.size().y / 2.0), - word.clone(), - Color32::WHITE, - ); - let x = x + word.size().x + 10.0; - painter.galley(pos2(x, rect.center().y - time.size().y / 2.0), time, Color32::WHITE); - } - /// The strip: the scene pads, the panic key, and the sound, along the /// bottom, or in columns beside a portrait picture. fn strip(&mut self, ui: &mut Ui, fx: &mut Fx, snapshot: &Snapshot, layout: &Layout) { @@ -749,8 +638,14 @@ impl Panels { return response.clicked().then_some(PadAction::Add); }; let on_air = snapshot.program.as_deref() == Some(pad.name.as_str()); - let tally = if on_air { Tally::Air } else { Tally::Off }; - let response = self.pad(ui, pad, tally, width, snapshot.shape); + // Off air, the scene on program is the one the stream opens on. + let live = self.engine.on_air().live().is_some(); + let (tally, tag) = match (on_air, live) { + (true, true) => (Tally::Air, None), + (true, false) => (Tally::Cue, Some("First")), + (false, _) => (Tally::Off, None), + }; + let response = self.pad(ui, pad, tally, tag, width, snapshot.shape); let mut action = (response.clicked() && pad.refused.is_none()).then(|| PadAction::Take(pad.name.clone())); response.context_menu(|ui| { let takeable = pad.refused.is_none() || on_air; @@ -783,7 +678,15 @@ impl Panels { /// A scene's pad, `width` wide, with its thumbnail once the compositor /// has drawn it, which it draws while the pad is on screen. - fn pad(&mut self, ui: &mut Ui, pad: &ScenePad, tally: Tally, width: f32, shape: f32) -> egui::Response { + fn pad( + &mut self, + ui: &mut Ui, + pad: &ScenePad, + tally: Tally, + tag: Option<&str>, + width: f32, + shape: f32, + ) -> egui::Response { let thumbnail = Thumbnail::Scene(pad.name.clone()); let size = vec2(pad.canvas.width as f32, pad.canvas.height as f32); let picture = self @@ -795,6 +698,7 @@ impl Panels { .picture(picture) .key(key.as_deref()) .tally(tally) + .tag(tag) .refused(pad.refused.as_deref()) .width(width) .shape(shape); @@ -806,7 +710,7 @@ impl Panels { } /// The key bound to `action`, as its tooltip shows it. - fn key(&self, action: &Action, ctx: &egui::Context) -> Option { + pub(super) fn key(&self, action: &Action, ctx: &egui::Context) -> Option { let hotkeys = self.hotkeys.as_ref()?; let bindings = hotkeys.bindings(); Some(bindings.get(action)?.shown(ctx)) @@ -1092,6 +996,9 @@ impl Panels { Setting::Show => { egui::ScrollArea::vertical().show(ui, |ui| self.output(ui)); } + Setting::Stream => { + egui::ScrollArea::vertical().show(ui, |ui| self.stream_settings(ui)); + } Setting::Hotkeys => { egui::ScrollArea::vertical().show(ui, |ui| self.hotkeys(ui, fx)); } @@ -1154,7 +1061,7 @@ impl Panels { repairs(ui, &self.engine.recorder.repairs()); let report = self.engine.health.lock().unwrap(); if report.relays.is_empty() { - ui.label("Not publishing; start with --connect to see how the stream is delivered."); + ui.label("Off air. Once live, this shows how the stream reaches viewers."); for problem in &report.problems { ui.colored_label(color(problem.verdict), &problem.cause); } @@ -1360,13 +1267,13 @@ fn edges(ui: &mut Ui, window: Rect) { } /// `elapsed` as a clock, hours first. -fn clock(elapsed: Duration) -> String { +pub(super) fn clock(elapsed: Duration) -> String { let seconds = elapsed.as_secs(); format!("{:02}:{:02}:{:02}", seconds / 3600, seconds / 60 % 60, seconds % 60) } /// A dashed outline around `rect`, as the pad that adds a scene has. -fn dashed(painter: &egui::Painter, rect: Rect, stroke: Stroke) { +pub(crate) fn dashed(painter: &egui::Painter, rect: Rect, stroke: Stroke) { let corners = [ rect.left_top(), rect.right_top(), From 3757f54d2977da285170ad6888b8cd6ef34f583a Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 11:33:22 -0800 Subject: [PATCH 03/23] chore: shots of the library and going live, for the PR body Co-Authored-By: Claude Opus 5.5 --- shots/end_stream.webp | Bin 0 -> 42426 bytes shots/going.webp | Bin 0 -> 29708 bytes shots/health.webp | Bin 0 -> 42840 bytes shots/library.webp | Bin 0 -> 48958 bytes shots/live.webp | Bin 0 -> 40484 bytes shots/live_hover.webp | Bin 0 -> 43382 bytes shots/on_air.webp | Bin 0 -> 42190 bytes shots/on_air_health.webp | Bin 0 -> 50352 bytes shots/settings_stream.webp | Bin 0 -> 49720 bytes 9 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 shots/end_stream.webp create mode 100644 shots/going.webp create mode 100644 shots/health.webp create mode 100644 shots/library.webp create mode 100644 shots/live.webp create mode 100644 shots/live_hover.webp create mode 100644 shots/on_air.webp create mode 100644 shots/on_air_health.webp create mode 100644 shots/settings_stream.webp diff --git a/shots/end_stream.webp b/shots/end_stream.webp new file mode 100644 index 0000000000000000000000000000000000000000..48d48595274f2e37b9817401e67f57b8138edd61 GIT binary patch literal 42426 zcmXVXQ*S|rNaoWr0PgrW2RWzZOArwv!RZZ)4w&loy!kbXT&Mtlb6QdR+55z|^!?x! z=BIY<^L;u``6zI|+nn>HfA6CMumxCO0sr8ByH}T1#J=9X>kZ~M5;W?+edh?&0oK3! zUitx-Rp|GKUxW{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xliq9|{srj_~G>xH}o~4#h)ah1W!>ljJT+825mi^H=hzhns;3-FaH`{kPTh zFbP#i=Cho>&YH0H1)+jp@inp;MdmJ$c=HR(6DmHiCvzr(rZ6&^-3>ROTmS0#LtM@X zb_dP*ZZsT4Vbz}TF+`iSnV-ZFof(w{k16AFIaav|9VgQBdxn<;Z=v+HLEz&YLx_Gs zkdvv}eDvKV!I&^>?m^;PrY`AG)#Que)#?=nitWA6#ao3#x7INSYp00_Dl6a|%tL{v z4gMSyt%@po0@eDRFk=1I{-6+3_;WjL&7RlsTvNjN7usKO3hA_hE9IE>YRoKZ9*&Gl zS+r__G@4zBQ1*BsaY1-jOJNdKD%Pc4HnVfhs^B(v3;Ja52nmHP|EqLXB^o}Y@+oz# z>;_vUMk7TY(m5j5haLKtCIM9C;*MTk9$GOnZlbHpW|puOnqE#Ry}D2n0HcHU_uKwF z%J#}e&I=%3Zho1K9#bC#4JTo0Y?#*H$2qj{F9mf%T1?EBsJ2ZofS!3e`&M{dCc=9; z*eF*JWZapTKWR{`6JBgY=K=w-p{cr-rtB;OHyd`3M*Nk6XFDjy7$t0vP3F5XndFnq zYgaX5`No(e)5eyn$4%-%S^VU4=_v|NXDk>g2f-ri-lOIx5HyVKxmVR-LmH3km=qhptP4kY#Wl4G!CgLcCav4!-~Z03=8N00000Dy#qi00000 zDYyUt07^grac^kV%l8VixuQ`KhNRTafB*mh8dJ(}00052Km{}a00001G*7e(_F4b{ L027n|00000t*tY( literal 0 HcmV?d00001 diff --git a/shots/going.webp b/shots/going.webp new file mode 100644 index 0000000000000000000000000000000000000000..9ff0dcba3a524f44012cdf8114299d945c989082 GIT binary patch literal 29708 zcmYJZW0)RWv^Dy+Z7c1xZQD-UcG|XW+qP}nwmWT`Uv|zp_twv z)DZws6%mwIk!L4(aR2~jy}o)Na_Zof)>&R-aj(wK-4!^y>g}xU)<-Y%3?mOS#S0Ct~ zi{Fn|HSbd25B!%NkA_eVre-FHlZ2^4^uhYD{aArakj;j{9b-Xy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6p$yp!NBdRu80zQ>!9@3 zOaIWc_7&lb;l!L#3^5D9)ErQ)r4`QDkB=~FNw_`Oxz0sl3X>EE><%IiDcMlMF)3tT5f%zc9oq{SJ)q_!mWY4=rDcAA0tN0005f3NY9J02Rm(Ltp}4P;z<#8?+-}01Qd#FaQTGUf9fLgafwY IG$;T70C~q{9RL6T literal 0 HcmV?d00001 diff --git a/shots/health.webp b/shots/health.webp new file mode 100644 index 0000000000000000000000000000000000000000..2aaf7e810df6f1f21f559f610cc282d49e57e953 GIT binary patch literal 42840 zcmZU)Q;;TG7p_~jZJS-TU0v?7U0t?q+qP}nwr$(|_FC&d=VHgsi;QH%jEN`T@s5#7 zQsUwYr9ePxV!{fl3Y{c}NRg4$(&RHw#P7j}o7sGJb6XtM z6l1rd<$P!UgmTn^#Lq0T)}Pi2^a^OaYyxfUCi!T3?Cumsd+SAEL~D0v=VJEk@iY5w zylTCc-;mA|e&!Y+9`Ei8Sn(YJW_)HnM}8jPZtsA%i>q;P3ZdVd+*wh ziEqlA>jUE>;LOL+3-(9x3-HzZO1RZ~$H&7#`D0e@+e;_|`16DKn)u~fmU<6Z^)>JH z{VDx~{aJi8`)Xaod?Y*pob<8^4Eq8AldrZP0&hJ|yQTmU0PeT#LF^jhgTPhpHJ~3* z4w(NLJ@5Pgd6008iP0RX(x zf93*4wA8`LTlQV% z;JaD$Fh3giEU+tC|N8*-M~l0%;hEKBGKaJHr!GQLhW^VQE(fMc0+2u@vaAei>n{aH zP+L;5GDWodhC~j~df8rM(T=4*z%wHwL}_js3g#YRp%eRLq_r`lay{3Xf|$|!=Z?Ucxeu6{D@LG()w2H#S;+xoap&f^ zCr-chCla=}O|Trlx!PWMpyqiA!vWvSP+K^C$hXVybp}f4cIi}n6~S_bs(#CcE)+7Q z6Z_M^*FrEHdqo#BNSk481oqOvyEp3!s94y?#H>|kyWr%EMU*UOWWPR(D#uJINKY{T zBIVC55O8+Wy<`=Ji(778%-c>eiWfqp4D)O`49%l$=zB*k7`I#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