feat(player): support selectable HLS and TS audio tracks#674
Conversation
Documentation previewThe documentation preview has been deployed for this pull request. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a537b40326
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
This PR adds end-to-end support for selectable audio tracks across the custom HLS/MSE playback pipeline, covering both (1) alternate HLS audio renditions via #EXT-X-MEDIA and (2) multiple elementary audio streams (PIDs) inside MPEG-TS, while preserving video continuity during audio switches.
Changes:
- Extend the HLS stack to parse/select
EXT-X-MEDIAaudio renditions and useEXT-X-PROGRAM-DATE-TIMEfor cross-rendition alignment. - Rework the transmux worker/pipeline to support a video pipeline plus separate/replaceable audio pipelines, with switching handshakes and state/events.
- Add UI + persistence for audio track selection (including a “switching” pending state and i18n strings), plus devlab scenarios for manual validation.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| web-ui/src/playback-engine/worker/transmux-worker.ts | Split worker into primary + audio pipelines; add audio track state + switching protocol. |
| web-ui/src/playback-engine/worker/pipeline.ts | Add PipelineOptions (forced track, selected TS audio PID), TS PID switching, and forced-track filtering. |
| web-ui/src/playback-engine/worker/messages.ts | Add worker commands/events for audio track selection + switch results. |
| web-ui/src/playback-engine/types.ts | Introduce audio track types/state + load options + preference key helper. |
| web-ui/src/playback-engine/remux/mp4-remuxer.ts | Add audio-only reset and silent-audio occupancy helpers for switching/timeline continuity. |
| web-ui/src/playback-engine/mse/playback-controller.ts | Handle new worker events; coordinate audio switch with MSE/PCM replacement. |
| web-ui/src/playback-engine/mse/media-source.ts | Support “preserve existing” init handling; add replaceAudioFrom() and MIME checks. |
| web-ui/src/playback-engine/index.ts | Re-export new audio track/load option types. |
| web-ui/src/playback-engine/hls/m3u8.ts | Parse EXT-X-MEDIA audio renditions + PROGRAM-DATE-TIME; add selection helpers. |
| web-ui/src/playback-engine/hls/hls-source.ts | Expose audio renditions in HlsInfo; add options for switch alignment and start positions. |
| web-ui/src/playback-engine/demux/ts-demuxer.ts | Track multiple audio streams in PMT; allow selecting/switching audio PID; emit audio track list. |
| web-ui/src/playback-engine/demux/pat-pmt-pes.ts | Add PMT audio stream model to carry codec/language and mapping metadata. |
| web-ui/src/playback-engine/backends/native-playback-backend.ts | Surface native audioTracks as audio-tracks-change events and allow selecting them. |
| web-ui/src/playback-engine/backends/mse-playback-backend.ts | Plumb new load options and audio track selection through MSE backend. |
| web-ui/src/playback-engine/audio/pcm-audio-player.ts | Add replaceFrom() to cut scheduled/queued PCM at a switch boundary. |
| web-ui/src/lib/player-storage.ts | Persist per-channel preferred audio track key. |
| web-ui/src/i18n/player.ts | Add localized strings for audio track UI + switch failure warnings. |
| web-ui/src/components/player/video-player.tsx | Wire audio track state/events, persistence, and error messaging into the player. |
| web-ui/src/components/player/player-controls.tsx | Add audio track selector UI with pending/switching state and accessibility attributes. |
| tools/devlab/README.md | Document new devlab scenarios for alternate/internal multi-audio coverage. |
| tools/devlab/devlab.py | Add devlab generators for alternate audio HLS masters and multi-audio TS scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
tools/devlab/devlab.py:710
- Invalid Python exception syntax:
except BrokenPipeError, ConnectionError:is a syntax error in Python 3 (comma-separated exceptions are not allowed). This will prevent devlab.py from running.
elif parts == ["multi-audio.ts"]:
self._multi_ts()
else:
self._send(404, "text/plain", b"not found")
except BrokenPipeError, ConnectionError:
pass
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd2eedea3d
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
EXT-X-MEDIAfor MPEG-TS and fMP4 sourcesWhy
The custom HLS/MSE pipeline previously selected only the variant playlist and ignored separately declared audio renditions. It also treated one PMT audio PID as authoritative, so programs with multiple elementary audio streams could not expose or switch tracks.
Track changes now prepare the replacement audio at a playable boundary, preserve the video pipeline, and anchor the new audio timeline at the current playback position. Unsupported codecs or failed switches leave the previous track active and surface a non-blocking warning.
Validation
pnpm run type-check:tscpnpm run lint:biome