Skip to content

Cast: pick audio and subtitle tracks on the TV; release 0.2.0 - #17

Merged
df49b9cd merged 2 commits into
mainfrom
cast/track-selection
Nov 14, 2026
Merged

df49b9cd merged 2 commits into
mainfrom
cast/track-selection

Conversation

@df49b9cd

@df49b9cd df49b9cd commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

While casting a movie or episode, the player's Audio and Subtitles menus (and the A/S keys) now work on the TV, and casting starts with the tracks playing here.

Also bumps the version to 0.2.0 (package.json, tauri.conf.json, Cargo.toml/lock, Flatpak metainfo release entry) and adds a WORKLOG entry; v0.2.0 is tagged from main after this merges.

How

  • Audio: Google's Default Media Receiver can't switch in-band audio tracks (that needs a custom receiver), so the relay's remuxer streams the picked audio stream, and a change reloads the item at the current position, staying paused if it was.
  • Subtitles: the remuxer decodes the picked text subtitle stream (SubRip, ASS, mov_text, WebVTT) on the way. The relay serves it as WebVTT at /cast/<token>/<n>.vtt next to the MP4, cue by cue on the receiver's clock. The receiver adds sidecar VTT through a <track> element, and Chromium parses its cues as they arrive. Each non-live LOAD offers that track and switches it on with EDIT_TRACKS_INFO once the TV plays it.
  • Not on the TV: picture subtitles (PGS, DVD) are listed as "Not on TV". Live channels get no subtitles.
  • Status and commands: the cast status now carries the item's tracks and which ones are playing. cast_control takes audio/subtitle, and cast_play takes the starting tracks.

Review

A multi-agent review with independent verification found these, all fixed here:

  • an out-of-bounds read when a demuxer adds streams mid-file
  • MP4 inputs seeking to read unpicked subtitle tracks
  • a repeated video request ending the subtitle response early
  • a stale media-session status switching subtitles on
  • a track change while paused starting playback
  • the menu waiting forever on items without subtitles
  • tracks lost when switching TVs
  • an early "Off" being ignored
  • the wrong label for live subtitle tracks

Testing

  • scripts/check.sh: all green (Rust tests, clippy, tsc, vitest, notices).
  • New unit tests for ASS→WebVTT conversion, cue timing, castProps and castTracksFrom.
  • Ignored end-to-end relay test, passing against an MKV with SubRip subtitles and an MP4 with mov_text subtitles, each with 2 audio and 2 subtitle tracks. It checks the picked audio track, the picked subtitle track's cues, and cue timing after a seek:
    TP_CAST_FILE=/path/file.mkv cargo test --lib relay_serves_tracks -- --ignored

Not yet tried on a real Chromecast. Things to check on a device:

  • subtitles from the still-open .vtt response show up and stay in sync
  • a track change reloads cleanly

Known limit: the subtitle line already on screen at a reload point is lost, because the reload starts at the keyframe.

@df49b9cd
df49b9cd added this pull request to stack #18 November 14, 2026 11:47
Base automatically changed from refactor/review-2 to main November 14, 2026 11:51
While casting a movie or episode, the player's Audio and Subtitles menus
(and the A/S keys) now work on the TV, and casting starts with the tracks
playing here.

Relay (remux.c, relay.rs)
- The remuxer streams the asked audio stream (falling back to
  player.audioLang) and reports every audio/subtitle stream before the
  first packet.
- One text subtitle stream (SubRip, ASS, mov_text, WebVTT) is decoded on
  the way: the asked one, else by player.subLang, else the file's default.
  Only that stream is read, so MP4 inputs don't seek for the others.
- The relay serves /cast/<token>/<n>.vtt next to <n>.mp4: WebVTT cues of
  that stream as they are decoded, on the receiver's clock. ASS styling
  is reduced to italic/bold/underline. A repeated request for the same
  URL takes over the cue feed instead of ending it.
- Picture subtitles (PGS, DVD) and live channels get no subtitles.

Session (session.rs)
- Every non-live LOAD offers the .vtt as a text track and switches it on
  with EDIT_TRACKS_INFO once the TV plays (not at LOAD: a track that never
  finishes loading may hold up playback), ignoring late statuses of the
  previous media session.
- The Default Media Receiver can't switch in-band audio, so a track change
  reloads the item where it is, staying paused when it was.
- Status carries the item's tracks and which are playing (tracksKnown,
  audioTracks, subtitleTracks, audio, subtitle); cast_control takes
  audio/subtitle, cast_play takes the starting tracks.

Frontend
- castProps maps the TV's tracks onto the mpv-shaped props (ids = stream
  index = mpv ff-index); control.setTrack/cycleAudio work while casting;
  castTracksFrom hands the current tracks over on castTo (also when
  switching TVs).
- The track menus show "Waiting for the TV…" until the tracks are known,
  "Not on TV" for picture subtitles, and the live-channel note.

Tests: auto-language and ASS→WebVTT/cue-timing unit tests, castProps and
castTracksFrom tests, and an ignored end-to-end relay test
(TP_CAST_FILE=... cargo test --lib relay_serves_tracks -- --ignored).
Not yet tried on a real Chromecast.
@df49b9cd
df49b9cd force-pushed the cast/track-selection branch from 01ac66c to 924060b Compare November 14, 2026 11:51
@df49b9cd df49b9cd changed the title Cast: pick audio and subtitle tracks on the TV Cast: pick audio and subtitle tracks on the TV; release 0.2.0 Nov 14, 2026
@df49b9cd
df49b9cd merged commit f5c02f7 into main Nov 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant