Skip to content

feat(player): play embedded text subtitles from the transcode's HLS stream - #611

Merged
Quick104 merged 1 commit into
Silo-Server:mainfrom
Rhainland:feat/hls-subtitle-renditions
Oct 17, 2026
Merged

Quick104 merged 1 commit into
Silo-Server:mainfrom
Rhainland:feat/hls-subtitle-renditions

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: Silo-Server/silo-server#1406
Validation tasks: changes #323 C4, #324 C4; likely helps C2 on the same tasks for forced tracks on large files.

When the server transcodes a video and the viewer picks a text subtitle stored inside the file, the app mounts a sidecar subtitle that the server builds by reading the whole video. On network storage that takes minutes. The video plays, but no subtitles show until the read finishes. Switching quality mid-movie, which moves direct play to a transcode, does the same.

With Silo-Server/silo-server#2620 (manual: Silo-Server/siloserver.org#229) the server can carry that subtitle inside the transcode's HLS stream. This PR has the phone and TV apps ask for that and play it.

Approach

  • The app sends hls_subtitle_renditions_v1 only when Media3 plays the HLS itself (native_hls_playback_v1), so Cast keeps its sidecars. A server_transcode_hls plan with subtitle.hls_rendition is validated, and the selected track gets no sidecar URL.
  • Phone and TV select the manifest track by Media3's GROUP-ID:NAME format ID, with a single non-sidecar track named NAME as a fallback. The selection counts as applied only once Media3 has selected it.
  • If the rendition can't be selected, the app replans with subtitle_hls_rendition_failed. The server returns the sidecar plan without restarting the video.
  • Replan and seek-reanchor checks compare the rendition. The server's decision fixture is vendored for the conformance tests, and docs/playback/README.md describes the flow.

Validation

Evidence

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

Surface and build: Android 16 emulator (Pixel 8 profile), this branch. Before uses the server's main build; after uses Silo-Server/silo-server#2620. Same file, storage throttle and start position. Tablet and foldable use the same phone player and were not captured. Android TV has its own selection code, which unit tests cover; it was not captured on a device.

Risks

  • Switching between embedded text tracks during a transcode restarts the stream at the current position, which takes a moment.
  • Against a server without the feature nothing changes: the app keeps the sidecar.

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; Codex CLI for review
  • Model(s): claude-opus-5-5 (implementation and review); gpt-6.1-sol (review)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: two independent reviews (claude-opus-5-5 and gpt-6.1-sol) of the full diff found no defects in this repository's change.

Advertise hls_subtitle_renditions_v1 when the HLS delivery is Media3's own
pipeline (native_hls_playback_v1), so Cast keeps its sidecars. A
server_transcode_hls plan with subtitle.hls_rendition is validated, and its
selected inventory row is projected with the rendition and no URL, so the
whole-file extraction is never mounted.

The rendition is an exact server selection, modelled on the native embedded
decision: phone and TV select the manifest track by Media3's GROUP-ID:NAME
format id (falling back to a single non-sidecar track labelled NAME), commit
only after it is selected, and on a failed mount replan failure_recovery with
subtitle_hls_rendition_failed so the server returns the sidecar plan without
tearing down video. Replan and seek-reanchor checks accept and compare the
rendition.

Vendor the server's hls-subtitle-rendition-decision_response.json fixture.
@silo-triage silo-triage Bot added the size/XL 500–999 added + deleted lines (all files); change volume, not priority. label Oct 17, 2026
@silo-kody

silo-kody Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f519623c-9e10-4d38-aa66-25ac8a66ecd4
📥 Commits

Reviewing files that changed from the base of the PR and between 4ab4e63 and db92fdb.

📒 Files selected for processing: 25
  • 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/SubtitleMountResolver.kt
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/player/VideoPlayerMediaSpec.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/HlsSubtitleRenditionTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/PlaybackCapabilityDetectorDolbyVisionTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/PlaybackSessionManagerStagedReplanTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/cast/CastPlaybackPreparerTest.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/MobileRecoveryReplan.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/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/TvPlayerViewModel.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/player/TvSubtitleRemountReselection.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/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/playback/PlaybackSubtitleIdentity.kt
  • shared/src/commonTest/kotlin/org/siloserver/silo/model/playback/HlsSubtitleRenditionProtocolTest.kt
  • shared/src/commonTest/resources/playback/v3/SOURCE
  • shared/src/commonTest/resources/playback/v3/hls-subtitle-rendition-decision_response.json

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The V3 playback protocol now supports HLS subtitle renditions. Android playback projects renditions into subtitle inventory, resolves them to manifest tracks, and handles selection failures through protocol V3 replanning.

Changes: HLS subtitle rendition playback

Layer / File(s) Summary
Protocol, identity, and feature negotiation
shared/src/commonMain/.../PlaybackModels.kt, shared/src/commonMain/.../PlaybackProtocolV3.kt, shared/src/commonMain/.../SubtitleTransition.kt, shared/src/commonMain/.../PlaybackSubtitleIdentity.kt, shared/src/commonTest/..., shared/src/androidUnitTest/..., docs/playback/README.md
The V3 contract adds rendition metadata, feature negotiation, validation, and subtitle identity rules. Fixtures, conformance tests, and playback documentation cover the new fields and behavior.
Session projection and rendition resolution
android-shared/src/androidMain/.../PlaybackV3Session.kt, android-shared/src/androidMain/.../SubtitleMountResolver.kt, android-shared/src/androidMain/.../VideoPlayerMediaSpec.kt, android-shared/src/androidUnitTest/.../HlsSubtitleRenditionTest.kt
Session projection attaches rendition metadata to the selected inventory row and leaves its URL blank. Resolution matches a unique Media3 rendition ID or an unambiguous name, and mounting excludes rendition-backed rows.
Subtitle staging and client transactions
android-shared/src/androidMain/.../PlaybackSessionManager.kt, android-shared/src/androidUnitTest/.../PlaybackSessionManagerStagedReplanTest.kt, androidApp/src/androidMain/.../MobileSubtitleTransactionAdapter.kt, androidApp/src/androidUnitTest/.../MobileSubtitleTransactionAdapterTest.kt, androidTvApp/src/androidMain/.../TvSubtitle*.kt, androidTvApp/src/androidUnitTest/.../TvSubtitleTransactionAdapterTest.kt
Session validation accepts eligible rendition plans. Mobile and TV subtitle transactions wait for manifest selection before committing, and route rendition mount failures through dedicated callbacks.
Rendition failure recovery
android-shared/src/androidMain/.../PlaybackSessionManager.kt, androidApp/src/androidMain/.../MobileRecoveryReplan.kt, androidApp/src/androidMain/.../PlayerViewModel.kt, androidTvApp/src/androidMain/.../TvPlayerViewModel.kt, android-shared/src/androidUnitTest/.../PlaybackSessionManagerStagedReplanTest.kt
Mobile and TV clients request protocol V3 replanning for rendition failures. Recovery recognizes the subtitle-selection failure classifications and tests cover fallback to a sidecar plan.

Priority: ⬇️ Low

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant PlaybackV3Session
  participant SubtitleMountResolver
  participant MobileSubtitleTransactionAdapter
  participant PlayerViewModel
  participant PlaybackSessionManager
  PlaybackV3Session->>SubtitleMountResolver: project rendition metadata and resolve manifest track
  SubtitleMountResolver->>MobileSubtitleTransactionAdapter: provide resolved subtitle identity
  MobileSubtitleTransactionAdapter->>MobileSubtitleTransactionAdapter: commit after manifest track selection
  MobileSubtitleTransactionAdapter->>PlayerViewModel: report rendition mount failure
  PlayerViewModel->>PlaybackSessionManager: request protocol V3 replan
  PlaybackSessionManager->>PlayerViewModel: return sidecar fallback plan
Loading

Possibly related PRs

  • Silo-Server/silo-android#200: Establishes the Playback Protocol V3 contract and session flow extended here with HLS rendition support.
  • Silo-Server/silo-android#293: Adds native embedded-subtitle selection and recovery extended here to embedded subtitles delivered as HLS renditions.

Suggested reviewers: quick104

Merge Risk: ⚪ Minimal · up to db92f

No actionable merge-blocking issue is established; the change is mergeable after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 63 functions across 22 files. (3 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely describes the main change: support for playing embedded text subtitles from the transcode's HLS stream.
Description check Passed The description directly explains the problem, implementation, validation, evidence, and risks for the HLS subtitle rendition changes.
Full details: Docstring Coverage

Explanation

Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 63 functions across 22 files. (3 skipped: 3 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@macroscopeapp

macroscopeapp Bot commented Oct 17, 2026

Copy link
Copy Markdown

Visible playback effect: a selected embedded text subtitle can now come from the HLS transcode, appearing during playback instead of waiting for whole-file sidecar extraction (android-shared/.../SubtitleMountResolver.kt, androidApp/.../MobileSubtitleTransactionAdapter.kt, and androidTvApp/.../TvSubtitleTransactionAdapter.kt). This reaches Android phone, tablet, foldable (folded and open), and Android TV.

  • Evidence is missing for this effect on the phone, tablet, foldable folded and open, and TV: Evidence: EVIDENCE_LINK is a placeholder, so the described Pixel 8 validation is not available to review. Please attach or link recordings of the before/after playback flow on each device; timing and the multi-step playback flow matter. Include the device and build or commit for each capture. The PR says the tablet, foldable, and TV were not captured, but these changes reach those devices.

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 impact: playback Can't play, stalls, or wrong media priority: P2 Limited scope, workaround exists, or polish labels Oct 17, 2026
@Quick104
Quick104 merged commit 33945a0 into Silo-Server:main Oct 17, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request impact: playback Can't play, stalls, or wrong media priority: P2 Limited scope, workaround exists, or polish size/XL 500–999 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants