Skip to content

feat(resolver): track selection and rendition audio names (TDD 0015, stage 1) - #40

Merged
includeamin merged 8 commits into
mainfrom
feat/vod-module-adapter-stage-1
Oct 11, 2026
Merged

includeamin merged 8 commits into
mainfrom
feat/vod-module-adapter-stage-1

Conversation

@includeamin

Copy link
Copy Markdown
Owner

Summary

First stage of the nginx-vod-module migration layer (TDD 0015, which this PR also adds): two additions to segmentor's own mapper answer that the later adapter needs to translate nginx's mapped-mode JSON faithfully. Both are optional fields, so existing mappers are unaffected, and native mappers can use them.

  • tracks on a single file, each rendition and each clip, in nginx-vod-module's syntax (v1-a1, a2, v0-a0). Selected audio is renumbered audio-1, audio-2… A selector that matches nothing of one kind still serves the rest, so the nginx default v1-a1 works on a file with no audio; only an empty selection fails the asset.
  • language, label, default on a rendition, for the one audio track it brings: HLS LANGUAGE/NAME/DEFAULT, DASH lang/<Label> (escaped). They need exactly one audio track to name; at most one rendition may be the default.

A selection or an override enters a URL version only when set, so every existing asset keeps its URLs; a change under an unchanged mapper version reloads the asset.

Not in this PR: the translator and the vod-module dialect (stages 2 and 3 of the design), adaptive playlists, DRM, URL compatibility.

Review

A fresh review found one real defect, fixed here with a test: a clip was trimmed on the whole file before its selection was applied, so a short track the clip drops could fail a later window. It also found that a label containing U+FFFE/U+FFFF would have produced an ill-formed DASH manifest; those are now refused. Deferred and noted in the spec: duplicate labels give duplicate HLS NAMEs, and overrides on a video rendition whose audio is not in the group have no effect (and no log line).

How it was checked

  • 586 library tests plus integration tests; make ci passes locally on the current stable Rust.
  • 19 mutation checks across the feature, each caught by a test. Two weak tests were found that way and strengthened (a version that hashed only the word "tracks", and nothing varying the language or default flag on its own).
  • End-to-end, byte for byte: a selected track is served exactly as the same track of the whole file, with the audio renumbered.

Known limits

  • The DASH <Label> is checked for well-formedness and escaping, not against a player or the MPD schema.
  • The translator is not written yet, and no real mapping response was available; the design is verified against nginx-vod-module's documentation only.
  • a_large_srt_converts_in_bounded_time has a hard 2 s wall-clock limit and fails on a busy machine; unrelated, but it can flake CI.

Test plan

  • make ci locally
  • CI

v1-a1, a2, v0-a0: for each kind of track, none, every one, or the nth in file
order. Applying it keeps the chosen tracks, numbers the audio afresh, and fails
only when nothing is left, so the default v1-a1 still serves a file with no
audio. Part of TDD 0015, stage 1.
The answer's tracks field takes nginx-vod-module's selector (v1-a1, a2, v0-a0)
for a single file. The selection is applied when the asset is assembled, the
audio left is numbered audio-1, audio-2 afresh, and the selection is part of the
URL version, but only when set, so an asset that serves every track keeps its
version. A changed selection under an unchanged mapper version reloads the
asset. Part of TDD 0015, stage 1.
A rendition or a clip takes the same tracks selector as a single file, so one file
can contribute its video to one rendition and a chosen audio track to another.
A bad selector names the rendition or the clip; one that leaves nothing fails
the asset. A clip's selection is part of its version, and a changed selection
under an unchanged mapper version reloads the asset. Part of TDD 0015, stage 1.
A rendition takes language, label, and default for the audio it brings, in place
of what its file says. The language replaces the track's, the label replaces the
name made from its position and language (HLS NAME, DASH Label, quoted and
escaped), and default makes it the group's default instead of the first; at most
one rendition may. They need exactly one audio track to name, are part of the
asset's version, and a change under an unchanged mapper version reloads it. Part
of TDD 0015, stage 1.
The mapper API describes tracks (on a file, a rendition, or a clip) and a
rendition's language, label, and default. TDD 0015 records stage 1 as
implemented and what it settled, and the roadmap marks track selection done.
…out of labels

A clip's track selection is applied to the file's index before the clip is
trimmed, so a track the clip drops can no longer decide where the window lies or
fail it by having no samples inside it (a second audio track that ends early
failed a later window). The test uses a file with such a track.

A rendition label with U+FFFE or U+FFFF passed validation and would have made the
DASH manifest ill-formed XML; it is now refused.

Both were found in review. Part of TDD 0015, stage 1.
@includeamin
includeamin merged commit e0d277e into main Oct 11, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant