Skip to content

feat(player): switch subtitles on the playing stream without a remount - #733

Closed
Quick104 wants to merge 2 commits into
feat/remux-subtitle-renditionsfrom
feat/in-place-subtitle-switching
Closed

Quick104 wants to merge 2 commits into
feat/remux-subtitle-renditionsfrom
feat/in-place-subtitle-switching

Conversation

@Quick104

@Quick104 Quick104 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #79, Silo-Server/silo-server#1406
Validation tasks: changes #323 C3, C4; changes #324 C3, C4, C5

Picking another subtitle replanned and then remounted the player, even when the media already playing carried the track: another embedded track of a direct-played file, or another rendition of an HLS stream. The viewer waited for the server and then sat through a rebuffer, the kind of unexplained wait #79 describes. Phone and TV now show such a pick at once and adopt the server's answer without remounting.

Approach

  • Server dependency:
  • The first commit models the new fields, and sends hls_subtitle_renditions_all_v1 only to a server that advertises it and only when the request already lists hls_subtitle_renditions_v1. It adds the checks the player needs: whether a row can be switched natively (native_selectable, or the client's own evaluation when a server sends none of the new fields), whether a row has a usable rendition, and whether a returned plan keeps the playing transport.
  • The second commit does the switching:
    • A qualifying pick shows at once, and its track_change replan goes out in the same step, including a pick queued while a commit is in flight. Off qualifies on the same streams, and Media3 must list the track.
    • For a subtitle pick only, PlaybackSessionManager marks the server's answer as in place when it keeps the transport the player renders (session, stream and headers, file, recipe, timeline, audio, claims, transformations and quirks) and changes only a subtitle the player selects in that media. Audio the player switched inside the file without a replan counts as the plan's audio. The first-frame report, local mutations and passthrough scope carry over.
    • The view models lay the adopted plan's subtitle decision, identity and menus over the mounted plan, so the item never remounts. Phone adopts without a new mount generation. TV adopts without a mount nonce and keys its mount effect on a mount key that ignores the subtitle decision; its two-phase publication confirms the selection on the tracks already published, and rolls back in place.
    • A failed replan, or a newer pick that needs one, puts the previous subtitle back. A plan that changes the transport or returns a sidecar is adopted with a remount, as before.
    • An in-place plan sends no plan_summary of its own; the transport's summary covers it. The server keys summaries, throughput samples and learned limits by connection, not by plan.
    • docs/playback/README.md ("Switching subtitles on the playing stream") records the design and the rollback rules.
  • Stack: based on feat(playback): accept HLS subtitle renditions on copy remuxes #732 (renditions on copy remuxes), which sits on fix(player): poll the phone's native subtitle mount deadline #731 (the phone's mount deadline). This change needs both.

Validation

  • ./gradlew testDebugUnitTest: pass, 6,664 tests, 0 failures. New tests cover the wire model and fixture round trips, the transport-keep check (including audio the player switched), in-place adoption in the session manager, the phone and TV adapters (immediate switch, Off, queued and superseded picks, a late mount, failure and restore), TV's local mountability, and the mount and stall-detector keys.
  • ./gradlew :android-shared:lintDebug :androidApp:lintDebug :androidTvApp:lintDebug: pass, no new findings.
  • :androidApp:assembleDebug and :androidTvApp:assembleDebug: pass.
  • Not run locally: the supply-chain scripts (no Ruby on the build machine; this change touches no build, dependency or workflow file), release bundles and release lint. CI runs them.
  • No device or emulator run.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-android/pr-733/

Risks

  • TV's two-phase publication and its in-place rollback are the most involved paths. Unit tests cover them; no device has run them.
  • The vendored fixtures follow the unmerged server branches. If the wire shape changes before those merge, the fixtures and the model need an update.
  • Off on direct play now switches in place on older servers as well; an answer that changes the transport still remounts.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code in T3 Code
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated. Nobody has verified it by hand yet, and no device or emulator run happened.
  • Adversarial review: two read-only reviews by separate Claude Code agents (claude-opus-5-5).
    • A TV-path review found six ways the player and the server could disagree: an adopted plan that dropped a PCM retry's audio claim and remounted, in-place adoption of quality and output replans, a stale sidecar committed without telling the server, a superseded switch left on screen, a dropped mount request, and an unneeded remount fallback. All are fixed.
    • A review of the whole original branch found no blocking bugs. Its notes on this change are fixed: the first pick after a local audio switch remounted, queued phone picks didn't switch in place, the phone's Off settle check, an uncancelled mount timer, a mount key recomputed on every recomposition, a stale comment, and a rule written twice. Its question about plan_summary for in-place plans was checked against the server and answered in the docs.

🤖 Generated with Claude Code

Note

Add in-place subtitle switching on the playing stream without a remount

  • Subtitle changes that keep the same stream (native tracks, HLS renditions, or Off) are now applied on the playing stream while a staged replan is pending, instead of waiting for a remount. Eligibility is checked by canSwitchSubtitleInPlace in InPlacePlanAdoption.kt and PlaybackPlanV3.appliesInPlaceOver in PlaybackProtocolV3.kt.
  • PlaybackSessionManager marks qualifying subtitle-track replans as in-place candidates. Adoption overlays the adopted plan with withInPlaceAdoption and keeps the active attempt's start time and local mutations; rollback restores the predecessor's state without a remount. Both mobile (PlayerViewModel.kt) and TV (TvPlayerViewModel.kt) view models adopt in-place plans without issuing a transport mount nonce.
  • Adds the HLS_SUBTITLE_RENDITIONS_ALL_V1_FEATURE protocol feature and per-row subtitle inventory fields (stream index, container track ID, native-selectability, HLS rendition) so the server can advertise which tracks are switchable.
  • Player screens now key effects on mountedPlaybackKey and mediaMountKey instead of the whole plan object, so a subtitle-only plan change no longer restarts playback effects.
  • Behavioral Change: replan and start requests gate both HLS subtitle-rendition extension features via gatedForHlsSubtitleRenditions in SequencedPlayback.kt; failed in-place switches restore the prior committed subtitle; local-mount timeouts are suppressed while an in-place replan is pending.

Macroscope summarized 8d723ee.

Quick104 and others added 2 commits October 30, 2026 09:29
…ck renditions

The server now names each embedded inventory row's track in the source
(stream_index, container_track_id), marks rows the player may switch to
on the original stream (native_selectable), and, under
hls_subtitle_renditions_all_v1, lists every cue-indexed embedded text
track as a rendition of an HLS plan's stream (inventory hls_rendition,
plus index on subtitle.hls_rendition).

Model those fields and send hls_subtitle_renditions_all_v1 the way the
remux feature is sent: only to a server that advertises it, and only
when the request already lists hls_subtitle_renditions_v1.

Add the predicates the player needs to switch without the server:
whether a row is native-switchable (native_selectable, or the client's
own evaluation when the server sends none of the C1 fields), whether it
has a well-formed rendition, and whether a returned plan keeps the
playing transport so it can be applied without a remount.

Re-vendor the playback-v3 fixtures from the unmerged server branch and
add round-trip tests for the native and every-track rendition decisions.
They must be re-synced from server main once those branches land.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Picking another subtitle used to replan and then remount the MediaItem,
even when the playing media already carried the track: a native track of
an original_http file, or a rendition of an HLS stream that lists every
embedded text track. The viewer waited for the server and then sat
through a rebuffer.

Phone and TV now show such a pick at once and send its track_change
replan in the same step, including a pick queued while a commit is in
flight. A row qualifies when the server marks it native_selectable
(falling back to the client's own evaluation when the server sends none
of the C1 fields), or has an every-track rendition; Off qualifies on the
same streams, and Media3 must list the track.

For a subtitle pick only, the session manager marks a staged candidate
inPlace when it keeps the transport the player renders and changes only
a subtitle selectable in that media. Audio the player switched inside
the file without a replan counts as the plan's audio. The manager
carries the transport's first-frame report, local mutations and
passthrough scope across the commit.

The view models lay the adopted plan's subtitle decision, identity and
menus over the mounted plan, so a change the client made to the mount
(a PCM retry's audio claim) stays and nothing remounts. Phone adopts
without a new mount generation. TV adopts without a mount nonce and keys
its mount effect on a media mount key that ignores the subtitle
decision; its two-phase publication confirms the selection on the tracks
already published, and an in-place publication rolls back by restoring
the predecessor's plan and reselecting its subtitle without a remount.
A failed replan, or a newer pick that needs one, restores the previous
subtitle locally. A plan that changes the transport or returns a sidecar
is adopted with a remount as before.

Stall detectors key on the mount rather than the plan id. A pick of
another server-placed track that cannot switch in place always goes to
the server, and TV counts a stale sidecar as mountable only while the
plan selects it. TV's same-route remount restores a native or rendition
track by its exact identity, since the reloaded playlist still marks the
original track DEFAULT, and its mount-request flow keeps the newest
request.

An in-place plan sends no plan_summary of its own: the transport's
summary covers it, and the server keys summaries, samples and learned
limits by connection. The design and its rollback rules are in
docs/playback/README.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 122 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0831ea83-8f13-4b3d-b2eb-7cd9f8e83cd6
Commits

Reviewing files that changed from the base of the PR and between d3a4ad0 and 8d723ee.

Files selected for processing: 34
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/player/InPlacePlanAdoption.kt
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/player/PlaybackSessionManager.kt
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/player/PlaybackV3Session.kt
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/player/SubtitleManager.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/InPlacePlanAdoptionTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/PlaybackSessionManagerStagedReplanTest.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/MobileSubtitleTransactionAdapter.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerScreen.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerViewModel.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/player/MobileSubtitleTransactionAdapterTest.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/player/TvPlayerScreen.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/player/TvPlayerViewModel.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/player/TvSubtitleIdentity.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/player/TvSubtitleTransactionAdapter.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/player/SubtitleTransactionIntegrationTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/player/TvLocalMountabilityTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/player/TvSubtitleTransactionAdapterTest.kt
  • docs/playback/README.md
  • shared/src/androidUnitTest/kotlin/org/siloserver/silo/model/playback/PlaybackProtocolV3ConformanceTest.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/model/playback/PlaybackModels.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/model/playback/PlaybackProtocolV3.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/model/playback/SubtitleTransition.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/repository/SequencedPlayback.kt
  • shared/src/commonTest/kotlin/org/siloserver/silo/model/playback/HlsSubtitleRenditionProtocolTest.kt
  • shared/src/commonTest/kotlin/org/siloserver/silo/model/playback/SubtitleInPlaceSwitchTest.kt
  • shared/src/commonTest/kotlin/org/siloserver/silo/repository/SequencedPlaybackTest.kt
  • shared/src/commonTest/resources/playback/v3/SOURCE
  • shared/src/commonTest/resources/playback/v3/capability_response.json
  • shared/src/commonTest/resources/playback/v3/conformance_matrix.json
  • shared/src/commonTest/resources/playback/v3/decision_response.json
  • shared/src/commonTest/resources/playback/v3/hls-subtitle-rendition-decision_response.json
  • shared/src/commonTest/resources/playback/v3/hls-subtitle-renditions-all-decision_response.json
  • shared/src/commonTest/resources/playback/v3/native-decision_response.json
  • shared/src/commonTest/resources/playback/v3/subtitle_inventory.json
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T13:33:13.224646Z 8d723ee PR opened
🔒 Security Review ✅ Completed 2026-10-30T13:33:52.566201Z 8d723ee PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@silo-triage silo-triage Bot added the size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. label Oct 30, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 30, 2026

Copy link
Copy Markdown

The Evidence section says Evidence: being published, but includes no captures or evidence link.

  • In-place subtitle switching on the phone app (androidApp/src/androidMain/.../player/PlayerScreen.kt and PlayerViewModel.kt): evidence is missing for Android phone, tablet, and foldable folded and open. Add before/after captures of the same playback screen and item for each form factor, naming each device and build or commit, plus a recording of the switch to show its timing and playback continuity.
  • In-place subtitle switching on TV (androidTvApp/src/androidMain/.../player/TvPlayerScreen.kt and TvPlayerViewModel.kt): evidence is missing for Android TV. Add before/after captures of the same playback screen and item, naming the device and build or commit, plus a recording of the switch and its timing.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@silo-triage silo-triage Bot added enhancement New feature or request evidence-required Needs before-and-after evidence before the Evidence check passes impact: playback Can't play, stalls, or wrong media priority: P2 Limited scope, workaround exists, or polish stacked Stacked on another open PR or branch labels Oct 30, 2026
@Quick104

Copy link
Copy Markdown
Contributor Author

Superseded by #770, which combines this change with the rest of the stack for review.

@Quick104 Quick104 closed this Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request evidence-required Needs before-and-after evidence before the Evidence check passes impact: playback Can't play, stalls, or wrong media priority: P2 Limited scope, workaround exists, or polish size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. stacked Stacked on another open PR or branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant