Skip to content

feat(player): play a copy remux's embedded text subtitle from its HLS stream - #953

Closed
Quick104 wants to merge 1 commit into
mainfrom
feat/remux-hls-subtitle-renditions
Closed

Quick104 wants to merge 1 commit into
mainfrom
feat/remux-hls-subtitle-renditions

Conversation

@Quick104

@Quick104 Quick104 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: changes #313 C4; changes #314 C4

When the server copy-remuxes a file to HLS (server_remux_hls) with an embedded text subtitle selected, the app mounts that track's sidecar URL. The server builds the sidecar by reading the whole source file, which takes minutes for a large file on network storage, so the subtitle appears late or not at all. A transcode already avoids this: since #821 the app plays its subtitle as a WebVTT rendition inside the HLS stream. The server does the same for a copy remux once the client sends hls_remux_subtitle_renditions_v1, but the app never sent it and refused hls_rendition on a remux plan.

Approach

  • Every video start sends hls_remux_subtitle_renditions_v1 next to hls_subtitle_renditions_v1; audiobooks don't. It is static like the base token: /api/v1 strips it, and a server that doesn't know it ignores it.
  • The plan adapter accepts subtitle.hls_rendition on server_remux_hls with the same checks as on a transcode. The load spec and controller already treat the rendition the same for both deliveries, and both use the same master playlist route, so the media credential scope for silo_rendition already covers it.
  • Picking another embedded text track on a remux replans instead of mounting its sidecar, but only when the decision's server_features list the remux token. Otherwise the pick stays a local sidecar mount, as before.

Affects iOS, tvOS and macOS (shared player code). The server side is already on silo-server main.

Validation

  • Build: iOS, tvOS and macOS build-only checks (Debug, Xcode 27.0) succeeded on c45f53c.
  • Unit tests: 190 tests in the protocol V3, media authorization, Aether boundary and buffering contract classes passed on an iOS 27.0 simulator (iPhone 17), ad-hoc signed.
  • Not run: playback against a server or on a device. tvOS and macOS have no test bundle.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-apple/pr-953/

Risks

  • A user's subtitle delay doesn't apply to a rendition AVPlayer draws, the same as on a transcode today.
  • Cue timing on a remux depends on the server's X-TIMESTAMP-MAP against fMP4 segments, including EVENT playlists that grow during playback. It needs checking on a device.

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 shell and file tools; GitHub CLI; Xcode 27.0 (xcodebuild, XcodeGen) on a Mac build service
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated. A maintainer approved opening it; no human has run it on a device yet.
  • Adversarial review: a separate read-only Claude Code session (claude-opus-5-5) reviewed the whole stack at high effort against the protocol contract and the server's wire shape. It found no problems in this change; its findings in the later all-track rendition change were fixed there.

🤖 Generated with Claude Code

Note

Add hlsRemuxSubtitleRenditionsFeature so HLS remux plans play embedded text subtitles

The player can now play a copy remux's embedded text subtitle directly from its HLS stream, instead of mounting a sidecar subtitle track.

  • Adds the hlsRemuxSubtitleRenditionsFeature capability constant in PlaybackProtocolV3Models.swift; it is advertised for video but not audiobook in ApplePlaybackV3Capabilities.swift and requires the existing HLS subtitle-rendition feature.
  • ApplePlaybackV3PlanAdapter.validate now accepts an HLS subtitle rendition on remux plans, not just transcode plans.
  • ProtocolV3SubtitleSelection.canApplyLocally takes a remux-rendition capability flag. An unmounted embedded non-bitmap subtitle is not applied locally on a remux plan when both rendition features are negotiated; the transcode path keeps its existing check.
  • Extends protocol tests in PlaybackProtocolV3Tests.swift for capability advertisement, remux plan validation, and local-selection behavior.
  • Behavioral Change: an unmounted embedded subtitle selection on an HLS remux plan is no longer applied locally when both rendition capabilities are present; check ProtocolV3SubtitleSelection.canApplyLocally in ProtocolV3SubtitleSelection.swift.

Macroscope summarized c45f53c.

… stream

A server_remux_hls plan with an embedded text subtitle mounted the
inventory sidecar, which the server extracts by reading the whole source
file: minutes on network storage before the first cue.

The client now sends hls_remux_subtitle_renditions_v1 next to
hls_subtitle_renditions_v1, like the base token, in the static feature
list (the server ignores it where unknown and strips it on /api/v1).
The server then carries the selected track as subtitle.hls_rendition on
the remux too.

- The plan adapter accepts hls_rendition on server_remux_hls with the
  same checks as on server_transcode_hls.
- The load spec and controller already treat the rendition by delivery
  class (no sidecar declared, the row resolves to AVPlayer's legible
  option), so the remote-HLS path plays it as it does a transcode's.
- Picking another embedded text track on a remux replans instead of
  mounting its sidecar, but only when the decision's server_features
  list the remux token; otherwise the server would answer with the same
  sidecar and the pick stays local.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Oct 30, 2026
@silo-kody

silo-kody Bot commented Oct 30, 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 ❌

@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:19:53.641420Z c45f53c PR opened
🔒 Security Review ✅ Completed 2026-10-30T13:20:58.085763Z c45f53c 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.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
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: d13edec2-69eb-4115-be82-890a71fb95c6
Commits

Reviewing files that changed from the base of the PR and between f334794 and c45f53c.

Files selected for processing: 6
  • iosApp/Tests/PlaybackProtocolV3Tests.swift
  • iosApp/iosApp/Screens/Player/PlayerViewModel.swift
  • iosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3Capabilities.swift
  • iosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3PlanAdapter.swift
  • iosApp/iosApp/Screens/Player/ProtocolV3/PlaybackProtocolV3Models.swift
  • iosApp/iosApp/Screens/Player/ProtocolV3/ProtocolV3SubtitleSelection.swift

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Walkthrough

The iOS client now advertises a remux-HLS subtitle-rendition capability and accepts subtitle-rendition plans for remux HLS. Local embedded-subtitle selection now considers that capability when deciding whether to apply a selection locally.

Changes: HLS Remux Subtitle Renditions

Layer / File(s) Summary
Advertise and validate remux-HLS renditions
iosApp/iosApp/Screens/Player/ProtocolV3/PlaybackProtocolV3Models.swift, iosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3Capabilities.swift, iosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3PlanAdapter.swift, iosApp/Tests/PlaybackProtocolV3Tests.swift
The client advertises the remux subtitle-rendition capability for video and excludes it from audiobook capabilities. Plan validation accepts rendition delivery for remux HLS. Tests cover capability reporting, plan construction, and contradictory plans.
Apply embedded subtitle selections
iosApp/iosApp/Screens/Player/ProtocolV3/ProtocolV3SubtitleSelection.swift, iosApp/iosApp/Screens/Player/PlayerViewModel.swift, iosApp/Tests/PlaybackProtocolV3Tests.swift
The local-selection check receives the remux rendition capability. Tests check when another embedded-track selection applies locally and when it requires replanning.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Possibly related issues

  • Issue 880 concerns applying subtitle selections during playback without stopping the session. This change handles remux-HLS selections through replanning, but does not address the issue’s inventory update contract.

Possibly related PRs

  • Silo-Server/silo-apple#821: Adds HLS subtitle renditions for transcode HLS, including capability reporting, plan validation, and local-selection replanning.
  • Silo-Server/silo-apple#842: Adds server-HLS embedded subtitle-rendition support that this change extends to remux HLS.

Suggested reviewers: rhainland

Merge Risk: Minimal · up to c45f5

The change enables remuxed HLS subtitle renditions; no concrete merge-blocking issue was identified.

Security architecture risk: Low · up to c45f5

The change reuses existing playback authorization and session-transition controls. No introduced security bypass was established, but server compatibility and interrupted remux playback were not independently validated end to end.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The newly exercised client behavior is bounded to an authenticated playback session and its designated media origin. The inspected change does not add credential authority across unrelated sessions or origins.

Security Findings and Attack Paths

  • inferred — No PR-specific credential-forwarding bypass was established along the inspected server-plan-to-media-request path. Newly accepted remux renditions use the existing authorization resolver rather than introducing a separate credential-bearing fetch path.

Trust Boundaries and Controls

  • observed — The media resolver checks credential-owner identity and confines requests to the established origin and session paths. Rendition authorization permits only a single silo_rendition query with video or subtitles on the existing HLS source path.

Resilience and Maintainability Implications

  • observed — The administrator-ended handler pauses playback and schedules dismissal but does not immediately clear pending track changes. The replan defer can drain queued work while an active prepared plan remains. Inspected bridge requests retain the same session and authority; server-side terminal enforcement was not inspected, so session revival is not an established finding.

Hardening Proposals

  • proposed — Make administrator-ended state immediately suppress queued replans and invalidate pending track intent, reducing reliance on server rejection during delayed dismissal. This would harden an existing shared transition, not remediate a demonstrated authorization bypass.
Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly describes the main change: playing embedded text subtitles from a copy-remuxed HLS stream.
Description check Passed The description directly explains the problem, implementation, validation, risks, and fallback behavior for the HLS remux subtitle changes.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 5 files. (1 skipped: 1 too large.)

Resolution

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

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@silo-triage silo-triage Bot added bug Something isn't working 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 labels Oct 30, 2026
@silo-triage

silo-triage Bot commented Oct 30, 2026

Copy link
Copy Markdown

The Evidence section still needs a playback capture for this visible change; build and unit-test results do not show subtitle delivery or timing. Add a short before-and-after recording of the same copy-remux case with an embedded text subtitle, including a seek, a track switch, and Off. Identify the device and build, and cover affected Apple devices or explain why a device is unaffected.

@Quick104

Copy link
Copy Markdown
Contributor Author

Superseded by #970, 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

bug Something isn't working 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/M 50–199 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant