Skip to content

feat(playback): accept per-codec audio channel ceilings - #3116

Merged
Quick104 merged 3 commits into
feat/playable-audio-defaultfrom
feat/codec-channel-ceilings
Oct 27, 2026
Merged

Quick104 merged 3 commits into
feat/playable-audio-defaultfrom
feat/codec-channel-ceilings

Conversation

@Quick104

@Quick104 Quick104 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #579
Validation tasks: no passed case is reached; touches #197 (Playback), not run yet
Stacked on #3115; merge that first.

A delivery's max_channels applies to every audio codec. A client that decodes AAC only in stereo but plays E-AC-3 or AC-3 5.1 (a Roku without multichannel AAC) cannot say so: max_channels: 2 would also force its 5.1 tracks to stereo, and leaving it out lets the server plan 5.1 AAC the client cannot decode. The Roku works around this by guessing the track before the start and, when the server still returns 5.1 AAC, stopping and starting again.

This change adds an optional per-codec ceiling. max_channels_by_codec: {"aac": 2} keeps every AAC conversion in stereo and never copies multichannel AAC to that delivery, while other codecs follow max_channels alone. /api/v2 advertises it as codec_channel_ceilings_v1, so a client knows the server honors it.

Approach

  • DeliveryCapabilityV3.MaxChannelsByCodec: keys normalized like codec names (E-AC-3 spellings become eac3; spellings of one codec keep the lowest positive ceiling, which also beats an unset one), at most 32 entries (stated in the OpenAPI schema), values up to 64; zero or less means no ceiling.
  • deliveryChannelCeilingV3 takes the lower of max_channels and the codec's entry. The copy checks, the finished-plan check (on the effective recipe's codec), and aacOutputChannelsV3 all use it.
  • /api/v1 drops the field before validation, as it does the buffering-quality fields, so the frozen surface neither rejects nor acts on it.
  • Contracts: OpenAPI, the v3 JSON schemas, generated web types, and playback fixtures (the new feature string) are regenerated. The two fix(sections): cap profile section item limits at 500 #3050 breaking-change approvals no longer match any change against main and are removed, as the contract check asks.

The start's audio choice from #3115 plans each candidate, so a per-codec ceiling also counts there: with {"aac": 2}, a multichannel AAC track no longer counts as playable without conversion.

Validation

  • TestStartRequestV3NormalizesCodecChannelCeilings covers the spelling merge. TestPlanPlaybackV3CodecChannelCeiling: with {"aac": 2}, TrueHD 7.1 and AAC 5.1 convert to stereo AAC; E-AC-3 5.1 plays as is. Planner-backed rows in TestPreferUnconvertedAudioTrackV3FollowsThePlanner cover the ceiling in the start's choice. TestV1StartIgnoresBufferingQualityFields now sends an out-of-range ceiling to /api/v1, which still plays.
  • Roku Ultra on an isolated sandbox: a DTS-HD MA 7.1 file plays stereo AAC on the first start, with no restart; a TrueHD 7.1 file with an AC-3 5.1 track still copies AC-3 5.1.
  • make verify-apiv2-contract reports two additive request properties. go build, gofmt, go vet, make lint-changed, make test-go (two jellycompat DV-strip tests fail locally on main too and pass in CI), and the playback-fixture, OpenAPI, API v2 fixture, web-type, and route-inventory checks pass.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-3116/

Risks

  • Clients that never send the field are unaffected. A client that sends it to an older server gets the field ignored, so it should send it only when the server lists codec_channel_ceilings_v1.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.

AI Disclosure

  • Harness: Claude Code in T3 Code
  • Tool(s): Claude Code subagents (code exploration and an independent diff review)
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, human verified
  • Review: an independent review found that /api/v1 validated the new field and that duplicate codec spellings resolved by map order; CodeRabbit found that an unset spelling could override a ceiling. All are fixed with tests.

🤖 Generated with Claude Code

A delivery's max_channels applies to every codec, so a client that decodes
AAC only in stereo but plays E-AC-3 5.1 had to cap both. The new optional
max_channels_by_codec caps one codec on top of max_channels: {"aac": 2}
keeps AAC conversions in stereo and still copies E-AC-3 5.1. /api/v2
advertises codec_channel_ceilings_v1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Oct 26, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 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-27T00:20:46.350153Z 2b88b1b New commits
🔒 Security Review ✅ Completed 2026-10-27T00:22:06.947394Z 2b88b1b New commits
ℹ️ 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 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

The playback API and planner add optional per-codec audio channel ceilings. The planner applies these ceilings during audio selection and plan validation. The /api/v1 paths remove the new field before validation. The breaking-approvals list is also emptied.

Changes: Codec-specific channel ceilings

Layer / File(s) Summary
Capability contract and validation
internal/playback/protocol_v3.go, contracts/api/v2/openapi.json, docs/design/schemas/playback-v3/v3/*-request.schema.json, web/src/api/v2/schema.ts, docs/architecture/playback-protocol-v3.md, docs/design/schemas/playback-v3/v3/fixtures/valid/*, internal/playback/testdata/protocol_v3/*
The protocol advertises codec_channel_ceilings_v1 and validates the per-codec map. API schemas, documentation, and response fixtures describe or include the field and feature.
Apply codec ceilings during planning
internal/playback/plan_v3.go, internal/playback/protocol_v3_test.go, internal/playback/audio_select_v3_test.go
Planning checks codec-specific limits alongside the delivery-wide limit. Tests cover AAC, TrueHD, and E-AC-3 planning outcomes and audio-track selection.
Preserve the frozen v1 request surface
internal/api/handlers/playback_v3.go, internal/api/handlers/playback_connection_test.go
The v1 start and replan paths clear MaxChannelsByCodec before validation. The compatibility test includes the field in a v1 request.

Breaking API approvals

Layer / File(s) Summary
Update breaking-approval list
contracts/api/v2/breaking-approvals.json
The approvals array no longer lists the two profile-section override operations.

Priority: Normal

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant PlaybackAPI
  participant DeliveryValidation
  participant PlaybackPlanner
  Client->>PlaybackAPI: submit delivery capability with codec ceilings
  PlaybackAPI->>DeliveryValidation: validate and normalize capability
  DeliveryValidation->>PlaybackPlanner: pass normalized capability
  PlaybackPlanner->>PlaybackAPI: return plan using codec-specific limits
  PlaybackAPI->>Client: return playback decision
Loading

Suggested reviewers: rhainland

Merge Risk: Moderate · up to 79377

A codec limit can be lost, and clients can submit schema-valid requests that the server rejects. Fix those mismatches before merging; also cover the separate v1 replan compatibility path.

Security architecture risk: Low · up to 79377

The new settings can tighten, but cannot raise, an existing channel ceiling. Playback ownership checks and recovery controls remain in place, and the older API discards the field. No new access or privilege expansion was identified. End-to-end resource containment and mixed-version recovery behavior were not fully verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated control scope is the authenticated user/profile's playback attempt. Codec ceilings can change its audio route and consume shared conversion resources, but restrictive max_channels values already exposed conversion planning before this PR. The inspection did not establish global quota guarantees or an increase in independently attackable resource scope.

Trust Boundaries and Controls

  • observed — Replan capability replacement occurs after authenticated user/profile checks, durable attempt ownership and API-surface checks, playback-attempt identity checks, and live-session validation. The new map does not replace those controls.

Resilience and Maintainability Implications

  • observed — The map uses the existing per-attempt persistence and replan lifecycle: capacity and session locks, request-digest leases, revision checks, and transport/session rollback on failed replacement commits. The inspected failure path also releases incomplete leases using a cancellation-independent context. These controls remain compensating transitions, not evidence that live transport and durable storage are one atomic transaction.
Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 6 files. (10 skipped:… 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 "feat(playback): accept per-codec audio channel ceilings" names the main change: an optional per-codec channel ceiling (max_channels_by_codec) for playback delivery. The changeset adds this …
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.
Description check Passed The description is specific and on-topic. It explains the problem (a delivery-wide max_channels cannot differ by codec), the new optional max_channels_by_codec field, the /api/v2 codec_channel_ceiling…
Full details: Title check

Explanation

The title "feat(playback): accept per-codec audio channel ceilings" names the main change: an optional per-codec channel ceiling (max_channels_by_codec) for playback delivery. The changeset adds this field to the protocol, planner, schemas, and tests, so the title matches the primary change. It uses a conventional-commit prefix and is 55 characters long.

Full details: Description check

Explanation

The description is specific and on-topic. It explains the problem (a delivery-wide max_channels cannot differ by codec), the new optional max_channels_by_codec field, the /api/v2 codec_channel_ceilings_v1 feature flag, the /api/v1 handling, the contract and fixture updates, the validation performed, and the risks. It matches the changeset summaries, which cover the protocol struct, planner logic, schemas, fixtures, and tests.

Full details: Docstring Coverage

Explanation

Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 6 files. (10 skipped: 9 unsupported, 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 api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase enhancement New feature or request go Pull requests that update go code impact: playback Can't play, stalls, or wrong media priority: P2 Limited scope, workaround exists, or polish stacked Base is another open PR; merge in stack order named in the body labels Oct 27, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Nitpick comments: 1
internal/api/handlers/playback_v3.go: 1

5031-5033: Trivial · Maintainability & Code Quality · Quick win

Cover the /api/v1 replan compatibility case.

The over-64 max_channels_by_codec case exists only for /api/v1 start. The replan route independently calls withoutNativeDeliveryFieldsV3 before validation, but no replan test sends this field. Add {"aac": 99} to an existing /api/v1 replan request and retain the successful-status assertion. This protects the replan call site without duplicating the start assertion.


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: af157630-e62e-4d00-9819-b9dd0f84a6d3
Commits

Reviewing files that changed from the base of the PR and between 953e3e1 and 793777c.

Files selected for processing: 16
  • contracts/api/v2/breaking-approvals.json
  • contracts/api/v2/openapi.json
  • docs/architecture/playback-protocol-v3.md
  • docs/design/schemas/playback-v3/v3/fixtures/valid/hls-subtitle-rendition-decision_response.json
  • docs/design/schemas/playback-v3/v3/fixtures/valid/learned-limit-decision_response.json
  • docs/design/schemas/playback-v3/v3/replan-request.schema.json
  • docs/design/schemas/playback-v3/v3/start-request.schema.json
  • internal/api/handlers/playback_connection_test.go
  • internal/api/handlers/playback_v3.go
  • internal/playback/audio_select_v3_test.go
  • internal/playback/plan_v3.go
  • internal/playback/protocol_v3.go
  • internal/playback/protocol_v3_test.go
  • internal/playback/testdata/protocol_v3/hls-subtitle-rendition-decision_response.json
  • internal/playback/testdata/protocol_v3/learned-limit-decision_response.json
  • web/src/api/v2/schema.ts

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

Comment thread contracts/api/v2/openapi.json Resolved
Comment thread internal/playback/protocol_v3.go Resolved
Quick104 and others added 2 commits October 26, 2026 20:15
When two spellings of one codec meet in max_channels_by_codec, a positive
ceiling now wins over zero or less (unset), and the lowest positive one
over the rest. The OpenAPI schema states the 32-entry limit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Quick104
Quick104 merged commit 36ac38d into feat/playable-audio-default Oct 27, 2026
26 of 27 checks passed
@Quick104
Quick104 deleted the feat/codec-channel-ceilings branch October 27, 2026 00:27
Quick104 added a commit that referenced this pull request Oct 27, 2026
…ersion (#3115)

* feat(playback): start on a track the client plays without conversion

When a v3 start names no audio track and the preference-based default
would need an audio conversion for this request, play another main track
in the same language that the request can take unconverted. A saved
series track still plays as saved.

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

* fix(playback): refine Auto audio on the route and version that play

The start's audio refinement now judges each track after the escalation
the start applies to a progressive remux with no route, and refines the
preference again when a buffered start moves to a lower version, instead
of carrying a track chosen on the requested file over by position.

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

* feat(playback): accept per-codec audio channel ceilings (#3116)

* feat(playback): accept per-codec audio channel ceilings

A delivery's max_channels applies to every codec, so a client that decodes
AAC only in stereo but plays E-AC-3 5.1 had to cap both. The new optional
max_channels_by_codec caps one codec on top of max_channels: {"aac": 2}
keeps AAC conversions in stereo and still copies E-AC-3 5.1. /api/v2
advertises codec_channel_ceilings_v1.

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

* fix(playback): keep a codec ceiling over an unset spelling

When two spellings of one codec meet in max_channels_by_codec, a positive
ceiling now wins over zero or less (unset), and the lowest positive one
over the rest. The OpenAPI schema states the 32-entry limit.

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase enhancement New feature or request go Pull requests that update go code impact: playback Can't play, stalls, or wrong media priority: P2 Limited scope, workaround exists, or polish size/L 200–499 added + deleted lines (all files); change volume, not priority. stacked Base is another open PR; merge in stack order named in the body

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant